Stap 2: Code
const int sensor = A3;
const int button = 5;const int buzz = 9;
int sensorValue;boolean alarmDiss = false;
void setup() { pinMode (button, INPUT); pinMode (buzz, OUTPUT); Serial.begin (9600);}
void loop() { sensorValue = analogRead (sensor); Serial.println (sensorValue); if (sensorValue >= 50 && !alarmDiss) { while (!digitalRead (button)) { tone (buzz, 800); delay (200); noTone (buzz); delay (200); } alarmDiss = true; } if (digitalRead (button)) { if (!alarmDiss){ tone (buzz, 800); } if (alarmDiss) { alarmDiss = false; noTone (buzz); delay (1000); } Serial.print ("Alarm Dismiss = "); Serial.println (alarmDiss); } else { noTone (buzz); }}