Author Options:

Help! How to code this (START SWITCH) Answered

   I have a problem on coding in my start button, when i pushed the start button, the process still working and need to finish its task given on the code then OFF,

The Problem is:

the problem is, when i pressed the start the button(ON), the process starts, but when i press the start button (OFF) , the Arduino finishes the entire code before it turns off. what i need is when i turn off the switch, the entire microcontroller(ARDUINO) is turn off, and when i start again the start button(ON), the process starts from the top.


The forums are retiring in 2021 and are now closed for new topics and comments.

6 years ago

There is an easier way to do this. Use a switch instead of a button.
Place it in line with the power source to the arduino. When you turn it
on the arduino turns on and runs your code. Turn the switch off an the
arduino powers off and the process stops. Uppon turning it back on again
the code runs from the start. If you want it to be a button here is a
simple soft latching power switch you can use so it is a button.