I’m using Arduino adk for a project since a few months but I have some problems with my code.
The concept is simple: when I press on a main button, a DC-motor connected to an H-bridge starts to run for 5 seconds. Then the motor begins to move in the opposite direction (possible with H-bridge) for an indefinite amount of time till it presses by its own a micro switch. At that moment the engine has to stop and the micro switch stays pressed. When I press on the main button again the whole cyclus recommence; the engine has to move in the opposite direction again for 5 seconds and go back till it presses on the micro switch…
Of course I know I can set up an amount of time and no micro switch is needed, but I really need one for my project.
At this moment I can let my engine turn 5 seconds, and let him turn back. But I can’t figure out what code I have to insert when the engine reaches the micro switch; it has to stop immediately and it has to be ‘ready to use’ when I give a signal from the main button.
I hope someone can help me for the code.
Thank you a lot!