/* Blink Turns an LED on for one second, then off for one second, repeatedly. Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to the correct LED pin independent of which board is used. If you want to know what pin the on-board LED is connected to on your Arduino model, check the Technical Specs of your board at: https://www.arduino.cc/en/Main/Products modified 8 May 2014 by Scott Fitzgerald modified 2 Sep 2016 by Arturo Guadalupi modified 8 Sep 2016 by Colby Newman This example code is in the public domain. https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink */ bool state = LOW; bool old_value = HIGH; bool button1 = LOW; bool button2 = LOW; bool button3 = LOW; bool button4 = LOW; bool button5 = LOW; bool button6 = LOW; // the setup function runs once when you press reset or power the board void setup() { // initialize digital pin LED_BUILTIN as an output. pinMode(A0, INPUT_PULLUP); pinMode(PD2, OUTPUT); pinMode(PD3, OUTPUT); pinMode(PD4, OUTPUT); pinMode(PD5, OUTPUT); pinMode(PD6, OUTPUT); pinMode(PD7, OUTPUT); } // the loop function runs over and over again forever void loop() { bool value = digitalRead(A0); if( value == LOW && old_value == HIGH){ state = 1 - state; } old_value = value; // value is now old and store the old value if(state == 1) { // if main button is pushed and the status flag is low digitalWrite(PD2, LOW); // turn on LED1 (HIGH is the voltage level) digitalWrite(PD3, HIGH); // turn on LED2 (HIGH is the voltage level) digitalWrite(PD4, HIGH); // turn on LED3 (HIGH is the voltage level) digitalWrite(PD5, HIGH); // turn on LED4 (HIGH is the voltage level) digitalWrite(PD6, HIGH); // turn on LED5 (HIGH is the voltage level) digitalWrite(PD7, HIGH); // turn on LED6 (HIGH is the voltage level) }else{ //buttonFlag = 0; digitalWrite(PD2, LOW); // turn off all the LEDs digitalWrite(PD3, LOW); digitalWrite(PD4, LOW); digitalWrite(PD5, LOW); digitalWrite(PD6, LOW); digitalWrite(PD7, LOW); } } /* while(digitalRead(A0)== LOW) { if(button1 == HIGH) { digitalWrite(PD3, LOW); digitalWrite(PD4, LOW); // turn off all other panels digitalWrite(PD5, LOW); digitalWrite(PD6, LOW); digitalWrite(PD7, LOW); } if(button2 == HIGH) { digitalWrite(PD2, LOW); digitalWrite(PD4, LOW); // turn off all other panels digitalWrite(PD5, LOW); digitalWrite(PD6, LOW); digitalWrite(PD7, LOW); } if(button3 == HIGH) { digitalWrite(PD2, LOW); digitalWrite(PD3, LOW); // turn off all other panels digitalWrite(PD5, LOW); digitalWrite(PD6, LOW); digitalWrite(PD7, LOW); } if(button4 == HIGH) { digitalWrite(PD2, LOW); digitalWrite(PD3, LOW); // turn off all other panels digitalWrite(PD4, LOW); digitalWrite(PD6, LOW); digitalWrite(PD7, LOW); } if(button5 == HIGH) { digitalWrite(PD2, LOW); digitalWrite(PD3, LOW); // turn off all other panels digitalWrite(PD4, LOW); digitalWrite(PD5, LOW); digitalWrite(PD7, LOW); } if(button6 == HIGH) { digitalWrite(PD2, LOW); digitalWrite(PD3, LOW); // turn off all other panels digitalWrite(PD4, LOW); digitalWrite(PD5, LOW); digitalWrite(PD6, LOW); } } */