// Quando se acionar o botão, o sistema deverá emitir um sinal sonoro de confirmação
// Ao se abrir o semáforo de pedestres, um sinal sonoro deverá ser emitido. A frequência do sinal
// sonoro deverá variar até que o tempo de abertura do semáforo se esgote (30 segundos).
int Som = 7;
unsigned int Sensor = 4;
int PinoSensor = 2;
int Pressao = LOW;
long multas = 0;
void setup() {
pinMode(Som, OUTPUT);
pinMode(Sensor, INPUT);
pinMode(PinoSensor, OUTPUT);
Serial.begin(9600);
}
void loop() {
tone(Som, 200);
delay(4000);
noTone(Som);
// Tocar o som por 200 milissegundos
for ( int x = 0; x < 10; x++) {
if (digitalRead(Sensor) == HIGH) {
digitalWrite(PinoSensor, HIGH);
if (Pressao == LOW) {
Serial.println("Movimento detectado!");
Pressao = HIGH;
}
}
else {
if (Pressao == HIGH) {
multas++;
Serial.print("Contador de multas: ");
Serial.println(multas);
Pressao = LOW;
}
}
if ( x >= 0 and x < 3) {
tone(Som, 300);
delay(4000);
noTone(Som);
delay(1000);
// 3 VEZES DE 5 SEGUNDOS GASTOS = 15
}
else if ( x >= 3 and x == 7) {
tone(Som, 3000);
delay(2000);
noTone(Som);
delay(1000);
// 3 VEZES DE 3 SEGUNDOS GASTOS = 9
}
else {
tone(Som, 5000);
delay(1000);
noTone(Som);
delay(1000);
}
// 3 VEZES DE 2 SEGUNDOS GASTOS = 6
}
return 0;
//
}