Created
August 26, 2013 15:06
-
-
Save whyisjake/6342433 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
int led1 = 13; | |
int led2 =12; | |
int button=7; | |
int value=0; | |
int ledon=0;// 0 = led off, 1 = led on | |
// the setup routine runs once when you press reset: | |
void setup() { | |
// initialize the digital pin as an output. | |
pinMode(led1, OUTPUT); | |
pinMode(led2, OUTPUT); | |
pinMode(button,INPUT); | |
} | |
// the loop routine runs over and over again forever: | |
void loop() { | |
value = digitalRead(button); | |
if (value == HIGH){ | |
ledon= ledon+1; | |
if(ledon== 4){ | |
(ledon=0); | |
} | |
delay(100); | |
} | |
if ((ledon == 1)||(ledon==3)) { | |
digitalWrite(led1, HIGH); | |
} else { | |
digitalWrite(led2, LOW); | |
} | |
if ((ledon==2)||(ledon==3)) { | |
digitalWrite(led1, HIGH); | |
} else { | |
digitalWrite(led1, LOW); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment