Coding guidance/help or re-write.

I need some help getting my sketch to work as it should, I have made a wiper controller with 3 intermittent and 1 slow speed, motor parking is a hall effect sensor, I can get the code to see the park sensor and it seems to work on intermittent 1 after a fashion. However, I am unsure if I have managed to code it so as to move the motor off the park switch, then make it run until it sees the parking switch again, then perform a delay and start over again. it would be easier if it had self parking built into the motor, unfortunately it does not.

Ideally I do not want to change the pin configuration, I do wonder if using interrupts may help and possibly a better method of making the delay.

The delay method I have used is also somewhat inadequate as it seems to hang if you move the rotary switch to any of the other positions, say from intermittent 3 to slow, it then starts to work again after the time the delay in seconds that it happens to be on.

My coding is limited at best. I would gladly pay someone who really knows how to write code and to get this working.

Timer_sub_loops_semi_working_version.ino (5.46 KB)

I don't know where timer0_millis is being updated but the way you are using it is just the same as delay()

Have a look at how millis() is used in a non-blocking way in the demo Several Things at a Time

If you want someone to write code for you ask in the Gigs and Collaborations section.

...R

Hi Robin2, that would explain a great deal, the timing sequences are bad to say the least, I will take a look at that, and by the way, thanks' for the suggestion about where to look for having the code written for me.

D..