THIS IS WHAT YOU NEED;
1.Arduino (in my case, Uno)
2.2 resistors at 220 ohms
3.2 LEDs (preferably different colors)
4.2 clock buttons
5. piezo
6.Breadboard or solderless breadboard
7. jumper wires
to start, let's program arduino
here is a sketch:
#define BUZZER_PIN 12 // pin with squeaker
#define PLAYER_COUNT 2 // number of cowboy players
// instead of listing all the pins one by one, we declare a pair
// lists: one with pin numbers with buttons, the other with
// LEDs. Lists are also called arrays.
int buttonPins [PLAYER_COUNT] = {3, 13};
int ledPins [PLAYER_COUNT] = {9, 11};
void setup ()
{
pinMode (BUZZER_PIN, OUTPUT);
for (int player = 0; player & lt; PLAYER_COUNT; ++ player) {
// using square brackets get the value in the array
// under the number indicated in them. Numbering starts from scratch.
pinMode (ledPins [player], OUTPUT);
pinMode (buttonPins [player], INPUT_PULLUP);
}
}
void loop ()
{
// give a signal "pli!", waiting for a random time from 2 to 7 seconds
delay (random (2000, 7000));
tone (BUZZER_PIN, 3000, 250); // 3 kilohertz, 250 milliseconds
for (int player = 0;; player = (player + 1)% PLAYER_COUNT) {
// if the player number "player" pressed the button ...
if (! digitalRead (buttonPins [player])) {
// ... turn on its LED and victory signal for 1 second
digitalWrite (ledPins [player], HIGH);
tone (BUZZER_PIN, 4000, 1000);
delay (1000);
digitalWrite (ledPins [player], LOW);
break; // There is a winner! We exit (English break) from a cycle
}
}
}
then we collect everything according to this scheme
You should get something like this
and now the game is ready to use
whoever clicks faster and won
and that’s probably all for today
AND YES, TAKE A QUESTIONNAIRE BELOW