Created
December 1, 2013 03:42
-
-
Save flaviocdc/7728275 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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