Go Down

Topic: How to use sensor signal trigger/stop code execution? (Read 384 times) previous topic - next topic


Hi I am very new to Arduino, so please excuse the simplicity of my question. 
I try to do this:
Read 1st. Proximity sensor signal, then trigger/start my code execution, once get 2nd. Proximity sensor signal, then stop my code execution, and do something else, such as rotate stepper motor 500 rev.

Could somebody give me similar example to achieve this?

Thanks very much in advance.


You need a state variable:

Code: [Select]

byte started = 0

if sensor is triggered then
 started = 1 - started

if started then
 do stuff that doesn't use large delays()


Go Up