|
| 1 | +const int buttonPin1 = 2; |
| 2 | +const int buttonPin2 = 3; |
| 3 | +int buttonState[10]; |
| 4 | +int timerStatus = 0; |
| 5 | +void setup() { |
| 6 | + // put your setup code here, to run once: |
| 7 | + pinMode(3,INPUT);//pushButton 1 |
| 8 | + pinMode(4,INPUT);//pushButton 2 |
| 9 | + pinMode(5,INPUT);//pushButton 3 |
| 10 | + pinMode(6,INPUT);//pushButton 4 |
| 11 | + pinMode(7,INPUT);//pushButton 5 |
| 12 | + pinMode(8,INPUT);//pushButton 6 |
| 13 | + pinMode(9,INPUT);//pushButton 7 |
| 14 | + pinMode(10,INPUT);//pushButton 8 |
| 15 | + pinMode(11,INPUT);//pushButton 9 |
| 16 | + pinMode(12,INPUT);//pushButton 10 |
| 17 | + |
| 18 | + Serial.begin(9600); |
| 19 | +} |
| 20 | + |
| 21 | +void loop() { |
| 22 | + // put your main code here, to run repeatedly: |
| 23 | + buttonState[0] = digitalRead(3); |
| 24 | + buttonState[1] = digitalRead(4); |
| 25 | + buttonState[2] = digitalRead(5); |
| 26 | + buttonState[3] = digitalRead(6); |
| 27 | + buttonState[4] = digitalRead(7); |
| 28 | + buttonState[5] = digitalRead(8); |
| 29 | + buttonState[6] = digitalRead(9); |
| 30 | + buttonState[7] = digitalRead(10); |
| 31 | + buttonState[8] = digitalRead(11); |
| 32 | + buttonState[9] = digitalRead(12); |
| 33 | + |
| 34 | + if(Serial.available()) |
| 35 | + { |
| 36 | + if(Serial.read() == 48)//48 ASCII code of 0 |
| 37 | + Serial.println("I am Working fine!!!"); |
| 38 | + } |
| 39 | + if(buttonState[0] == HIGH) |
| 40 | + Serial.println(1); |
| 41 | + if(buttonState[1] == HIGH) |
| 42 | + Serial.println(2); |
| 43 | + if(buttonState[2] == HIGH) |
| 44 | + Serial.println(3); |
| 45 | + if(buttonState[3] == HIGH) |
| 46 | + Serial.println(4); |
| 47 | + if(buttonState[4] == HIGH) |
| 48 | + Serial.println(5); |
| 49 | + if(buttonState[5] == HIGH) |
| 50 | + Serial.println(6); |
| 51 | + if(buttonState[6] == HIGH) |
| 52 | + Serial.println(7); |
| 53 | + if(buttonState[7] == HIGH) |
| 54 | + Serial.println(8); |
| 55 | + if(buttonState[8] == HIGH) |
| 56 | + Serial.println(9); |
| 57 | + if(buttonState[9] == HIGH) |
| 58 | + Serial.println(0); |
| 59 | + |
| 60 | + |
| 61 | +} |
0 commit comments