100 Students Said Box
This is a diagram of how i build the box of buttons to the game 100 students said
int inPin1 = A0; //Detector boton1
int inPin2 = A1; //Detector boton2
int val1=0;
int val2=0;
void setup() {
// put your setup code here, to run once:
//pin13 Bocina
pinMode(13, OUTPUT);
//pin 12 Primer player
pinMode(12, OUTPUT);
//pin 8 segudno Player
pinMode(8, OUTPUT);
//boton primer player
pinMode(inPin1, INPUT);
//boton segundo player
pinMode(inPin2, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
//apagamos las luces
digitalWrite(12, LOW);
digitalWrite(8, LOW);
//leemos quien de los dos jugadores presiono primero
val1 = digitalRead(inPin1);
val2 = digitalRead(inPin2);
if(val1==HIGH){
val2=LOW;
digitalWrite(12, HIGH);
digitalWrite(8, LOW);
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13,LOW);
delay(50);
delay(3000);
}
if(val2==HIGH){
val1=LOW;
digitalWrite(12, LOW);
digitalWrite(8, HIGH);
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13,LOW);
delay(50);
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13,LOW);
delay(50);
delay(3000);
}
}