Skip to content

Instantly share code, notes, and snippets.

@Sugeevan

Sugeevan/HACK Secret

Created April 22, 2016 15:56
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 Sugeevan/961b2ebd50623be7fd1475ecfa86e4a5 to your computer and use it in GitHub Desktop.
Save Sugeevan/961b2ebd50623be7fd1475ecfa86e4a5 to your computer and use it in GitHub Desktop.
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