const int buzzerOne = 9;
const int buzzerTwo = 10;
bool inChair = false;
bool personFound = false;
int buzzTone1 = 1500;
int buzzTone2 = 3000;
void setup() {
Serial.begin(9600);
Serial.println();
pinMode(buzzerOne, OUTPUT);
pinMode(buzzerTwo, OUTPUT);
}
void loop() {
while (personFound == false) {
int val = analogRead(0);
if (Serial.available() > 0) {
String data = Serial.readString();
if (data == "x\r\n") {
val = 0;
personFound = true;
Serial.println("Stop buzzers");
}
}
if (val >= 5) {
tone(buzzerOne, buzzTone1);
delay(500);
noTone(buzzerOne);
tone(buzzerTwo, buzzTone2);
delay(500);
noTone(buzzerTwo);
Serial.println(val);
}
}
}