This is my code guys. I need to disable button 1, 2 and 3. Example when I push button 1, I can do it only once. I also need a reset function so that I can use again button1, button 2 and button 3.
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 7, 6, 5, 4, 3);
int count = 60;
int start = 12;
int reset = A5;
int startTime;
int buttonStart;
int buttonStop;
int buttonReset;
int button1Pin = 9;
int button2Pin = 10;
int button3Pin = 11;
int button1 =0;
int button2 = 0;
int button3 = 0;
int buzz1;
int buzz2;
int buzz3;
int answer=0;
void setup() {
pinMode(start, INPUT);
pinMode(reset, INPUT);
// pinMode(led1, OUTPUT);
//pinMode(led2, OUTPUT);
//pinMode(led3, OUTPUT);
pinMode(button1Pin, INPUT);
pinMode(button2Pin, INPUT);
pinMode(button3Pin, INPUT);
pinMode(2, OUTPUT);
lcd.begin(16,2);
Serial.begin(9600); // setup serial
}
void loop() {
buttonStart = digitalRead(start);
buttonReset = digitalRead(reset);
button1 = digitalRead(button1Pin);
button2 = digitalRead(button2Pin);
button3 = digitalRead(button3Pin);
if (buttonStart==HIGH){
startTime=HIGH;
answer=0;
}
if (startTime==HIGH)
count--;
if (buttonReset==HIGH)
{count=60;
answer=0;
}
if (count==0)
startTime=LOW;
if(answer==LOW){
if (button1==HIGH){
digitalWrite(2,HIGH);
delay(100);
digitalWrite(2,LOW);
startTime=LOW;
answer=HIGH;
}
if (button2==HIGH){
digitalWrite(2,HIGH);
delay(100);
digitalWrite(2,LOW);
startTime=LOW;
answer=HIGH;
}
if (button3==HIGH){
digitalWrite(2,HIGH);
delay(100);
digitalWrite(2,LOW);
startTime=LOW;
answer=HIGH;
}
}
lcd.print("TIME ");
lcd.print(count);
Serial.println(answer);
delay(900);
lcd.clear();
}