Simple switch/motor project-Serious setup issues (Halp)

Okay, I'll try to make this short. I am extremely new to arduino, coding, wiring, all that good stuff. Class project now has me learning as I go. I've got the basics, but have spent 2 weeks trying to research how to do this and am coming up empty. (It's probably super simple.)

I have a switch that I want to use to start a motor. It is an external light switch, and I have a continuous dc motor. With the switch in the off position nothing should be happening. When the switch gets flipped there should be a 15 second delay before the motor moves a short distance and stops, without looping or starting up again.

Sounds simple, but for some reason I can't figure this out. As soon as I give the board power the 15 second delay starts and the motor moves, regardless of what position the switch is in, and flipping the switch doesn't effect it. Is it possibly because of the light switch I'm using?

I'm really at a loss here and have asked a friend or two about it and they thought it would be simple but have been running into the same issues and are baffled.

Any help would be great! My code has changed so many times at this point I don't even know where to start or where to go with it.

Thanks in advance!!

When you have posted a diagram showing how everything is connected and the code you are trying to use we can very likely help.

It sounds like your code should all be in setup() and should be looping round checking for the switch to be on. Then when it is on doing the 15 second wait, then running the motor. Is that what you think you're doing? If so show us.

Steve

Have you tried a serial.print() statement to find out what the Arduino thinks the input state is at power-up?

Slipstick that is exactly it! I originally had it all looping and then realized I could move it to setup instead. And Dougp, I didn't even think about that. :slight_smile: However, after your advice and spending a day at work thinking on it, I realized it might just be the type of switch I have versus the way I needed to code it. I got a different switch from a friend and wired everything up and low and behold it works now!

So thank you for your time and willingness to help. Sometimes just thinking/talking/writing things out reveals that it was the simplest solution all along!!

Zatica:
So thank you for your time and willingness to help. Sometimes just thinking/talking/writing things out reveals that it was the simplest solution all along!!

Yep, it's too easy to wrapped around the axle.