Hello there,
the problem i'm facing is that i can't get the arduino to read the 2nd input (pushbutton) even though i'm sure it's connected properly because i tried to use it as the 1st one instead and it worked..
so i have 2 pushbuttons and 4 LED's and i want the 1st pushbutton to make LED1 light and LED2 blink and then when i press the 2nd pushbutton i want LED 2 stop blinking and just be lit and LED3 to start blinking.. but i can't get the 2nd pushbutton 2 work... it doesn't read it at all.. so can someone please see my code and tell me what's wrong.. or why it doesnt read it?
#define LED 13 // THE PIN FOR THE LED
#define SENS1 0
//VARIABLES
int pin1 = 1;
int pin2 = 2;
int pin8 = 8;
int pin9 = 9;
int pin10 = 10;
int pin11 =11;
int sensorValue = 0;
int oldSensorValue=0;
boolean blinking = false;
void setup () {
pinMode (8, OUTPUT);
pinMode (9, OUTPUT);
pinMode (10, OUTPUT);
pinMode (11, OUTPUT);
pinMode (1, INPUT);
pinMode (2, INPUT);
}
void loop (){
oldSensorValue = sensorValue;
sensorValue = digitalRead(pin1);
if(sensorValue == HIGH && oldSensorValue == LOW){
digitalWrite(pin8, HIGH);
if(sensorValue == HIGH && blinking == true){
blinking = false;
}
else if(sensorValue == HIGH && blinking == false){
blinking = true;
}
}
if (blinking == true) {
digitalWrite(pin9, HIGH);
delay(200);
digitalWrite(pin9, LOW);
delay(200);}
sensorValue = digitalRead(pin2);
if (blinking == false && sensorValue == HIGH){
digitalWrite(pin9, HIGH);
while (pin9, HIGH) {
digitalWrite(pin10, HIGH);
delay(200);
digitalWrite(pin10, LOW);
delay(200); }
}
else if (blinking == false && sensorValue == HIGH){
digitalWrite(pin9, HIGH);
digitalWrite(pin10, HIGH);
while (pin10, HIGH) {
digitalWrite(pin11, HIGH);
delay(200);
digitalWrite(pin11, LOW);
delay(200); }
}
}
thank you =)