Pages: [1]   Go Down
Author Topic: testing for a pushed button switch  (Read 526 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Regards  Philip
Logged

Pages: [1]   Go Up
Jump to: