#define BUZZER_PIN 7 #define PLAYER_COUNT 2
int buttonPins[PLAYER_COUNT] = {2, 13};
int ledPins[PLAYER_COUNT] = {3, 12};
void setup()
{
pinMode(BUZZER_PIN, OUTPUT);
for (int player = 0;
player < PLAYER_COUNT;
++player) {
pinMode(ledPins[player], OUTPUT);
pinMode(buttonPins[player], INPUT_PULLUP);
}
8}
// comments
void loop()
{
// delay(ms)
delay(random(1000, 3000)); // random time
// from 1 to 3 seconds
// tone(pin, frequency)
// tone(pin, frequency, duration)
tone(BUZZER_PIN, 2000, 400); // 2 kilohertz,
// 400 milliseconds
delay(1000);
for (int player = 0; ;
player = (player+1) % PLAYER_COUNT) {
// if player push button
if (digitalRead(buttonPins[player])) {
// turn on the LED and the victory signal
// for 2 seconds
digitalWrite(ledPins[player], HIGH);
tone(BUZZER_PIN, 3500, 300);
delay(1000);
digitalWrite(ledPins[player], LOW);
// There is a winner! Exit the for loop
break;
}
}
}
void setup()
{
void setup()
{
pinMode(0, OUTPUT);
digitalWrite(led_red, HIGH);
delay(1000);
digitalWrite(led_red, LOW);
}
void loop()
{
digitalWrite(0, HIGH);
digitalWrite(led_red, HIGH);
}
СРОЧНО ПОЖАЛУЙСТА НАЙДИТЕ В ЧЕМ ОШИБКА ПОЖАЛУЙСТА ​
Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Copyright © 2025 SCHOLAR.TIPS - All rights reserved.