If you want to build your own control system, you can review some options at Control Systems. The option described here, to build your own controller device, is that you could leverage an Arduino device. For that option, first lets cover some background on the approach, and then the steps to take to build this controller.
Unlike smartphones or PCs, Arduino boards (and other prototype development boards) have digital output options built into them. Typically the large number of digital output options makes it easier for them to control a variety of external actuators. If you want to use data ports to control items like an LED light or an electric motor, you won't need additional electronics for any handshake. However, you shouldn't wire up a digital output directly to a motor since a motor will probably draw more current than the digital output is rated for.
|IO Address||Memory Address||Signal Name||Direction|
You typically shouldn't wire up a digital output directly to a motor since a motor will probably draw more current than the digital output is rated for. Instead you should have a small amplifying switch circuit, and a separate power supply to drive the motor. This can be done with a transistor circuit to amplify any of the digital output signals from Arduino ports. A diode and capaciter in parallel to the motor prevents problems with the circuit when the motor is stopped and it momentarily acts as a little generator. This circuit can be used for driving a small motor from just about any digital output like a smartphone parallel port, PC parallel port, etc., not just this project. Here's a diagram of the circuit you want to wire up.
Every time a byte or bit is written to the data ports, the data will be latched (saved), and will remain present until something new is written. Thus you just need to set a bit high to turn on a device, wait while you want the device on, and then set the bit low to turn the device off.
To do this, write a program that sets the bits you want to turn on in a byte or char variable, and send that byte to the digital port, and call a wait routine. Once the wait routine is done, clear the bits and write them to the digital port. The data will be held as long as the program is in the wait routine.
You can't wire up a digital output directly to a motor and be able to control the motor in three different states: stopped, forward, reverse. Instead you will need two digital outputs, one to control direction and one to turn the motor on and off. You then need a circuit called an H-bridge in order to be able to switch the current direction to the motor. This could be built from scratch with transistors, but it's such a popular circuit you can get ICs that have H-bridge or half H-bridge circuits. The L298 is a popular dual packaged full H-bridge IC, while the L293 (aka SN754410) is a popular quadruple package half H-bridge IC. You can use two half H-bridge circuits with a little other circuitry to form the equivalent of a full H-bridge so these two ICs offer similar capabilities. For this example we use an L293 since it's easier to put this chip into a solderless breadboard. By using a digital inverter such as a 74LS04, we can tie two half H-bridges driver inputs together so that one always has the opposite state as the other. Here's a diagram of the circuit you want to wire up.
Note that in an h-bridge circuit there is a separate voltage supply for the motors vs. for the digital logic, similar to the simple motor circuit described above. With an Arduino, the digital logic voltage can be provided by the Arduino board. The motor voltage can be supplied independently and can be different than the 5V supplied for the digital logic.
Now you need to write a program that sets both a direction bit and a bit to turn on or off the motor, and call a wait routine. The data will be held as long as the program is in the wait routine. Once the wait routine is done, clear the bits and write them to the digital port to turn the motors off before turning them on in a different direction. Here's an example of the code that, with the above circuit, can be used to drive a rover with tank drive. It should be able to drive the rover forward, then reverse, and then turn before repeating.
int motorPin2 = 2;
int motorPin3 = 3;
int motorPin4 = 4;
int motorPin5 = 5;
extern void stop()
extern void setup()
extern void loop()
// forward on one side and reverse on the other
// results in turning
Here's a video of a Arduino (AVR) controlled Snap Rover robot using this h-bridge circuit and this code.
Copyright (C) 2019 R. J. Kuhn. Please note that you are not allowed to reproduce or rehost this page without written permission.