Skip to content

Instantly share code, notes, and snippets.

@flaviocdc
Created December 1, 2013 03:42
Show Gist options
  • Save flaviocdc/7728275 to your computer and use it in GitHub Desktop.
Save flaviocdc/7728275 to your computer and use it in GitHub Desktop.
int led = 13;
int incomingByte = 0;
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
Serial.print("#TXT|TXT|TEXT$");
delay(5000); // delay in between reads for stability
if (Serial.available()) {
char buffer[256];
memset(buffer,0,sizeof(buffer));
int count = Serial.readBytesUntil('$', buffer, 256);
if (count == 0) {
Serial.print("#");
Serial.print("NAO|LI|NADA");
Serial.print("$");
} else {
Serial.print("#");
Serial.print(buffer);
Serial.print("$");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment