Skip to content

Instantly share code, notes, and snippets.

@francis2110
Created November 4, 2014 08:37
Show Gist options
  • Save francis2110/7138aba38a819352ddf1 to your computer and use it in GitHub Desktop.
Save francis2110/7138aba38a819352ddf1 to your computer and use it in GitHub Desktop.
int ledPin=38, ledPin1=39,ledsONOFF=0, baudRate=9600;
//blue led on=1, off=0
//red led on=3, off=2
void setup(){
pinMode(ledPin,OUTPUT);
pinMode(ledPin1,OUTPUT);
Serial.begin(baudRate);
}
void loop(){
if(Serial.available()>0){
int ledsONFF=Serial.read();
if(ledsONFF==0){
digitalWrite(ledPin,LOW);
}
else if(ledsONFF==1){
digitalWrite(ledPin,HIGH);
}
else if(ledsONFF==2){
digitalWrite(ledPin1,LOW);
}
else if(ledsONFF==3){
digitalWrite(ledPin1,HIGH);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment