Skip to content

Instantly share code, notes, and snippets.

@ericellb
Created April 27, 2015 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericellb/12d7337396f6646ef3f8 to your computer and use it in GitHub Desktop.
Save ericellb/12d7337396f6646ef3f8 to your computer and use it in GitHub Desktop.
const int ledPin2=2;
const int ledPin3=3;
const int ledPin4=4;
void setup()
{
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(ledPin4, OUTPUT);
Serial.begin(9600);
}
void loop()
{
// If data is available, then read it!
if (serial.available() > 0)
{
int serialVal = serial.read()-'0';
}
// If serial val is 1, turn on LEd4, turn off Led3
if (serialVal == '1')
{
digitalWrite(ledPin3, LOW);
digitalWrite(ledPin4,HIGH);
}
// If serial val is 0,
// turn on LED2. Turn off Led3
// delay for 100ms
// turn of LED2, turn on LED3
// delay for 100 ms
if (serialVal == '0')
{
digitalWrite(ledPin4,LOW);
digitalWrite(ledPin2, HIGH);
digitalWrite(ledPin3, LOW);
delay(100);
digitalWrite(ledPin3, HIGH);
digitalWrite(ledPin2, LOW);
delay(100);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment