I am trying to design a simple sketch with a DC motor to run constantly, then switch directions when one of two limit switches are pressed. Basically, a constant back and forth movement that changes directions when the respective limit switch is pressed. I attempted to look for a sketch that was already designed, but there are a bazillion hits and all seem to have people yelling at the OP for some nonsense and end up at a dead end. Imaging the idea is a "moving target" that moves back and forth on a sliding rail. The closest thing I have found is a "camera slider" but these seem to be adding too many features. I simply need back and forth with speed adjustment.
I have access to just about anything, but currently have a mechanism that is not arduino controlled. It's a 12v motor driver with a respective motor connected to a DPDT switch (6pin) and a 9v battery that has a B10K pot adjusting the speed. Currently I have to manually flip the switch back and forth to change movement, but someone had mentioned to me that I could program an arduino to automatically change the direction with a limit switch on both sides of the track instead of me having to keep flipping the switch.
Has anyone come across something like this? I have to believe there is something out there...?
Thanks for a well written description of the project.
You'll never find exactly the code Your project needs.
Reading 2 end switches should be an easy task.
Using a motor driver looks like needed to me. I use a double H-bridge good for some 20 Amps. (43 Chinese Amps...)
The code snippet for just running forward looks like:
Thank you so much! This info will greatly help. In the video link above, at about 24:00 is almost exactly what I am attempting to make, however, my plan was for continuous movement until the mechanism is powered off. I am going to wire it in as the video show just to get some hands-on education, however, I believe what Railroader posted may be my necessary route. Thanks again for the link to the video above; that guys seems to have all of the projects that I wish to build!
Railroader:
Thanks for a well written description of the project.
You'll never find exactly the code Your project needs.
Reading 2 end switches should be an easy task.
Using a motor driver looks like needed to me. I use a double H-bridge good for some 20 Amps. (43 Chinese Amps...)
The code snippet for just running forward looks like:
I bought some Chines SSRs listed to handle 25 Amps. Then, on Youtube, a guy was opening up exactly such an SSR and inspected the Triac used. The Triac was rated 12 Amps, with heat sinking!