I wanted to know if there is a certain code that could allow you to:
1: Turn on the DC motor
2: Put it in reverse
3: Stop the motor
I don’t want the entire code, just the lines that would do the above stated things. I DO NOT want to use a switch if possible. I would just look it up online but everywhere I look uses a switch. I also would prefer not to use a variable resistor.
Again, I don’t want the entire code, that I can figure out on my own, just the commands that would do this. Alternatively, if you know another source that could point me in the right direction that would be very helpful as well.
What motor? There aren’t many motors that you can drive directly off an Arduino pin. The pins can’t handle much current. You could use a transistor to turn a motor on and off, but not to reverse it. You can use an array of transistors to build an H-bridge, but it would be much simpler and cheaper to buy one.
There’s really no way round it if you want to be able to drive the motor both directions.
It is just a DC hobby motor. I actually might have a L293D somewhere
Maybe this will help?
You can use a L293 to drive 2 DC motors as long as each motor draws less than about 600mA. Be aware that the L293 will drop around 2 ( or more) volts so you need to raise the motor supply voltage some to compensate. Power the motors from the Arduino supply at your own risk. The 754410 chip is a drop in replacement for the L293 and is a better, though not ideal, driver.