Halt DC Motor for extended period of time

Hey there,

I’m helping build a portable solar station for my end of year project. Everything is done, the only thing I have left to do is to add some halting feature that will stop the motor from running for an hour, then will start it again for a second, then stop again for an hour. The motor i meant to drive the solar panel to track the sun. I realize a different motor would have been much better to use like a stepper or a servo, but I have to work with what I have. So far my code has start, stop, direction ( drive the motor in FWD and REV) and jog functionality, and the motorspeed is controlled by a 100k potentiometer.

Heres the code so far:

Week_7.ino (5.03 KB)

An Arduino is not very good at time keeping (compared to a clock) but I suspect you don't need precise timing for your project. Something that is approximately an hour should be OK i.e. 1000 * 60 * 60 millisecs

Have a look at how millis() is used to manage timing without blocking in Several Things at a Time.

And see Using millis() for timing. A beginners guide if you need more explanation.

,
Your program is very difficult to read. Pleas use the AutoFormat tool to indent it consistently so the different blocks of code are easily seen. It would also be a good idea to move a lot of the code from loop() into short single-purpose functions such as checkUserButtons(), moveMotorFwd(), moveMotorRev() etc. It will make the control logic easier to see. Have a look at how the code is organized in Planning and Implementing a Program

...R

I've decided to shorten the delay considerably for presentation purposes. The motor should spin for one second, then delay for fifteen seconds. This will be done 6 times so that the motor travels abut 96 degrees ( which is how much we'd like it to spin)

trussell97:
I've decided to shorten the delay considerably for presentation purposes.

Almost all that I said in Reply #1 remains relevant

...R

If this is related to your other thread, and it seems like it is, contact a moderator about merging the two. Cross posting is frowned upon.