I am very new to Arduino, but I need some help with a school project. If you take a look at the attached picture, how would I both setup and code the motor to rotate counterclockwise for a certain amount of time (enough time that would allow the hand sanitizer bottle to pump down), have the motor stop for one second, and then have the motor rotate clockwise for the same amount of time as the first rotation so that after it is all said and done, the motor will be back in the same position that it started in???? Again, I am very new to using Arduinos so the more descriptive/easy-to-understand the better. I am not sure if this makes a difference or not but what you can probably tell from the attached PDF is that this motor will be triggered by a motion sensor. Sorry to be too needy, but a quick reply would be so greatly appreciated, I am trying to work against a deadline and this is pretty much my only hope.
I am very new to Arduino, but I need some help with a school project. If you take a look at the attached picture, how would I both setup and code the motor to rotate counterclockwise for a certain amount of time (enough time that would allow the hand sanitizer bottle to pump down), have the motor stop for one second, and then have the motor rotate clockwise for the same amount of time as the first rotation so that after it is all said and done, the motor will be back in the same position that it started in???? Again, I am very new to using Arduinos so the more descriptive/easy-to-understand the better. I am not sure if this makes a difference or not but what you can probably tell from the attached PDF is that this motor will be triggered by a motion sensor. Sorry to be too needy, but a quick reply would be so greatly appreciated, I am trying to work against a deadline and this is pretty much my only hope.
Cross-posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.
Repeated cross-posting will result in a timeout from the forum.
In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum board. It contains a lot of other useful information. Please read it.
I too am a relative Arduino novice, although an experienced practical electronics hobbyist. Perhaps it’s because I’m ‘old school’, but I would personally use an appropriately wired DPDT relay to handle the motor’s direction. The Arduino program’s contribution would then be to switch the relay on or off. The relay would, of course, need its own power supply.
If you choose that approach, let us know if you need advice on the relay wiring. FWIW, I used one in my curtain controller twenty years ago, and it’s still running well.
Your opinion, mine differs. What's wrong with a DPDT relay? Inexpensive, plentifully available (such as the examples linked below which I found in seconds), and you only need to install one of them, not a pair.
Fair point. My approach would be an arrangement like that here, a fragment of the ageing curtain controller circuit I mentioned. My additional standard SPCO relay adds flexibility and I reckon would overall be cheaper than a paired set.
I'm happy to concede that both are reasonable alternatives.
Paul__B:
Actually, you do not use a DPDT relay for reversing!
You use two SPDT relays - which are more readily available and significantly more robust.
One for forward, and one for reverse.
One of the readily available twin relay modules would likely suit.
Playing with a geared 12 Volt, 3 - 5 Amps I really don't like Your solution. My motor almost fly away when Power is applied. Reversing that motor using relays is núgly. I use a H-bridge and upon a direction change the motor is slowed down, ramped down to a low speed before the direction is switched. After the directions swich the motor is given a ramp up.
It would put lots of stress to the rest of the mechanical mechanism as well as to the motor to just boom, bang, switch the direction.
Railroader:
It would put lots of stress to the rest of the mechanical mechanism as well as to the motor to just boom, bang, switch the direction.
Actually, you have just explained one of the reasons why using two SPDT relays is better than a DPDT reversing relay. If you accidentally lose power to (or switch) the reversing relay, that is what happens.