Skip to content

Instantly share code, notes, and snippets.

@DILL44 DILL44/arduino_led.ino
Last active Dec 23, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.