Created
July 23, 2014 23:04
-
-
Save AlexanderSavochkin/5c5ab3cd8826a21e6fc2 to your computer and use it in GitHub Desktop.
Arduino hardware serial interconnection example
This file contains 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
enum { LED_PIN = 13 }; | |
void setup() | |
{ | |
pinMode(LED_PIN, OUTPUT); | |
Serial.begin(9600); | |
} | |
void loop() | |
{ | |
if (Serial.available()) //New data arrived | |
{ | |
char command = Serial.read(); | |
switch (command) | |
{ | |
case '1': | |
Serial.println("Hello"); | |
break; | |
case '2': | |
for (int i = 1; i < 5; ++i) | |
{ | |
digitalWrite(LED_PIN, HIGH); | |
delay(50); | |
digitalWrite(LED_PIN, LOW); | |
delay(50); | |
} | |
break; | |
default: | |
Serial.println('?'); //Not recognized commands | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment