animal training

Hi!

I need some help. I need to train an animal to drink water when an LED lights. How can I write this in the code: An LED lights once for 1 second, and just then (the LED must have been lit, I don´t care if now is turned off), an IR beam (emitter+receiver) is able to be read as broken in a time window of 4 seconds to activate 1 solenoid valve for 1 second. And so on.

If you know any code that could help me, please post it. Thank you!

What if the animal is not thirsty?

Keeping track of time passing with millis() and reading the sensor while waiting for time to elapse is what you are after. That is the basis of "blink without delay". Check it out, come back with questions.

thank you! I will check that...

PS: the animal must be thirsty :cold_sweat: