johnwasser:
Are you SURE you only want to look at the button when the alarm is sounding?!? You will only be able to set the limit to a value lower than the current limit.if (flexSensorReading < 100) {
Serial.println("Alarm! Set Angle Exceeded");
digitalWrite(Piezo, HIGH);
if (digitalRead(inPin)) {
// LoggedPosition=flexSensorReading;
}
delay(100);
digitalWrite(Piezo, LOW);
}
The alarm works using the code above but I changed it to "if (flexSensorReading.> 250)" because the sensor works better in the other direction. What I want is to make the 250 a string or integer thats the current position of the sensor on power up or pressing the button. So, say you bend it 45 degrees and press the button, the flex sensor is released and it monitors for the flex sensor to reach 45 or beyond and starts alarming.. Then you bend it at say 80 degrees and press the button and it does the same but for 80 degrees. Look at the sketch I posted to see one way to correct this programming error.