Skip to content

Instantly share code, notes, and snippets.

@an-dr
Created February 15, 2020 07:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save an-dr/280aa9cfe963d02fc7d877b24becd274 to your computer and use it in GitHub Desktop.
Save an-dr/280aa9cfe963d02fc7d877b24becd274 to your computer and use it in GitHub Desktop.
#include <Arduino.h>
int getChar(FILE *fp) {
while (!(Serial.available()))
;
return (Serial.read());
}
int putChar(char c, FILE *fp) {
if (c == '\n') {
putChar((char)'\r', fp);
}
Serial.write(c);
return 0;
}
void setup() {
Serial.begin(9600);
fdevopen(putChar, getChar);
printf("Hello %s!", "there")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment