Go Down

Topic: How to use sensor signal trigger/stop code execution? (Read 621 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

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131