int b1 = 9;
int b2 = 8;
int
//button status
boolean bu1 =0;
boolean bu2 =0;
//Status of whether or not a button has been pressed
int hold = 0;
void setup() {
//allows you to see on a computer who buzzed in first
Serial.begin(9600);
//Lockout Status LED pin with is statndard on the Arduino Board(s)
pinMode(13, OUTPUT);
//Button inputs defined
pinMode(b1, INPUT);
pinMode(b2, INPUT);
//The delay allows time for the voltage to stabilize (exp. because the electronics are not removed from the buttons!)
delay(1000);
}
void loop() {
//Read to see if a button is pushed
if(hold == 0){
bu1 = digitalRead(b1);
bu2 = digitalRead(b2);
//player 1
if(digitalRead(b1)==HIGH||digitalRead(b2)==LOW)
{
hold=1; //lockout the other users
Serial.println("Player 1");
}
//player 2
if(digitalRead(b2)==HIGH||digitalRead(b1)==LOW){
hold=1; //lockout the other users
Serial.println("Player 2");
}
}
else{
digitalWrite(13, HIGH); // set the LED on to indicate that the other users are locked out
}
}
void time(){
delay(15000);
}
[font=Verdana][/font]
Sir i need a little help..i am a beginner here,,i dont think this gonna work.. please help for better code..
i want to output the first button who pressed first. thanks
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
int hold=0;
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if(hold==0)
{
if(buttonState1||buttonState2){
delay(5000);
{
if (buttonState == HIGH) {
// turn LED on:
hold=1;
digitalWrite(ledPin1, HIGH);
}
if(buttonState2==HIGH){
hold=1;
digitalWrite(ledPin2, HIGH);
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
{
well thanks sir..i have sought a new code..i just need it yout reply...