Go Down

Topic: testing for a pushed button switch (Read 817 times) previous topic - next topic


Trying to get my head around this..

I have a loop containing some code to run a stepper motor for a few steps then fire a relay,
then repeat that sequence till I unplug.
It's driving a homebrew macro slide....

What I want is for the software to wait till I've pushed a "start" button before it goes into the loop,
but from then on, to ignore the button...
Question is, do I need two loops?
One for testing the state of the button and the other to run the macro slide...

Very much a newb at this so many apologise for asking what is probably a silly question..

Thanks for any help folks

Regards  Philip


It would help to see your code.

One thing, easy, that you could do is stay in setup() until the switch is pressed, using a while loop. When the switch is pressed, break out of the while loop, which will let setup() end and loop() to begin looping.
The art of getting good answers lies in asking good questions.


Thanks for that, done as you sugested and put a digitalRead in a while loop
in setup and that works perfectely..

Regards  Philip

Go Up