Ive tried looking at states and state detection and I get how they work, Im just still struggling to apply it to using an analogue read. Not sure how to make the mp3 sound for 1 second only when the analogue read first gets a reading of over 4.0 and then not play anything else until the analogue read drops bellow a certain reading. Ive tried using millis and states, im just confused on the appropriate way of using them in this context.
void loop(){
currentMillis = millis();
b=analogRead(A5);
b=b*5/1023;
Serial.println(b); //prints the values coming from the sensor on the screen
if(b>=4.0&&b<=5.00)
{digitalWrite(5,HIGH);
myDFPlayer.play (1);
delay (300);
}
still having to use a delay at the moment, and this obviously just loops round and round while its receiving this analogue read