Skip to content

Instantly share code, notes, and snippets.

@DILL44
Last active December 23, 2015 12:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DILL44/6635370 to your computer and use it in GitHub Desktop.
Save DILL44/6635370 to your computer and use it in GitHub Desktop.
void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);
}
void loop() {
if (Serial.available() > 0) { // if there is data coming from the serial port
int data = (int)Serial.read(); // get that data and print it
Serial.println(data);
if (data == 1) { // do what you want with this data
digitalWrite(13, HIGH);
}
else if(data == 2){
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
}
else if(data == 3){
while(1){
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
}
else{
digitalWrite(13, LOW);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment