my name is lucas, i'm teacher and building a game buzzer
this is the project : Hardware Hump Day: DIY Game Buzzer for National Trivia Day - News - SparkFun Electronics
everything ir going well and working, but i would like to introduce this little detail on code, the led blinking will help me see if the arduino is runing well, thnks:
"int ledPin = 11;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
}
"
can someone help me ? I know, it's a very simple and basic code, but i've never used arduino before.
this is the code i´m using :
"
//assign buttons to pin
int redBut = 2;
int yelBut = 3;
int bluBut = 4;
int greBut = 5;
//assign LED to pins
int redLED = 6;
int yelLED = 7;
int bluLED = 8;
int greLED = 9;
//initialize button state to 0
int redButState = 0;
int yelButState = 0;
int bluButState = 0;
int greButState = 0;
//locked out state variables
boolean pause = false;
int secs = 5000;
//assign speaker pin
int sound = 12;
int soundSecs = 1000;
void setup() {
//begin serial communication
Serial.begin(9600);
//initialize button pins to input
pinMode(redBut, INPUT);
pinMode(yelBut, INPUT);
pinMode(bluBut, INPUT);
pinMode(greBut, INPUT);
//initialize LEDs to output
pinMode(redLED, OUTPUT);
pinMode(yelLED, OUTPUT);
pinMode(bluLED, OUTPUT);
pinMode(greLED, OUTPUT);
//initilize LEDs to Off
digitalWrite(redLED, LOW);
digitalWrite(yelLED, LOW);
digitalWrite(bluLED, LOW);
digitalWrite(greLED, LOW);
}
void loop() {
if (pause == false) { //only works when buzzers are unlocked
//read button states
redButState = digitalRead(redBut);
yelButState = digitalRead(yelBut);
bluButState = digitalRead(bluBut);
greButState = digitalRead(greBut);
//repeat the following code block for each button included. make sure to update the variable names when copy and pasting this block.
if (redButState == 1) { //if red button is pushed
pause == true; //puts program into lock mode so other players cannot buzz in
digitalWrite(redLED, HIGH); //lights up corresponding LED
tone(sound, 900, soundSecs); //plays team tone for one second
Serial.println("TEAM RED"); //Serial indication of first team to press buzzer
delay(secs); // five second delay - enforces lockout for other players
digitalWrite(redLED, LOW); //turn LED off
pause == false; //turn off lockout mode
}
if (yelButState == 1) {
pause == true;
digitalWrite(yelLED, HIGH);
tone(sound, 700, soundSecs);
Serial.println("TEAM YELLOW");
delay(secs);
digitalWrite(yelLED, LOW);
pause == false;
}
if (bluButState == 1){
pause == true;
digitalWrite(bluLED, HIGH);
tone(sound, 500, soundSecs);
Serial.println("TEAM BLUE");
delay(secs);
digitalWrite(bluLED, LOW);
pause == false;
}
if (greButState == 1){
pause == true;
digitalWrite(greLED, HIGH);
tone(sound, 300, soundSecs);
Serial.println("TEAM GREEN");
delay(secs);
digitalWrite(greLED, LOW);
pause == false;
}
}
}
"