-
-
Save Sugeevan/961b2ebd50623be7fd1475ecfa86e4a5 to your computer and use it in GitHub Desktop.
This file contains 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 led = 13; //pin for led | |
int led2 = 12; //pin for led | |
const int BUTTON = 7; //pushbutton is connected | |
int val = 0; // store input state | |
// the setup routine runs once when you press reset: | |
void setup() { | |
// initialize the digital pin as an output. | |
pinMode(led, OUTPUT); //LED's are an output | |
pinMode(led2, OUTPUT); | |
pinMode(BUTTON, INPUT); //BUTTON is an input | |
} | |
// the loop routine runs over and over again forever: | |
void loop() | |
{ | |
val = digitalRead(BUTTON);// read input value and store it | |
if (val == HIGH){ | |
digitalWrite(led, HIGH);// turn on LED | |
digitalWrite(led2, HIGH);// turn on LED | |
} | |
else{ | |
digitalWrite(led, LOW); | |
digitalWrite(led2, LOW); | |
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) | |
delay(100); // wait for a second | |
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW | |
delay(100); | |
digitalWrite(led2, HIGH); | |
delay(100); | |
digitalWrite(led2, LOW); | |
delay(100);} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment