Introduction: Touchpad Controlled Digital Servo Motor
Here is a quick and simple project where we control a digital servo motor with the slide of our finger on a PS/2 touchpad with the help of an Arduino microcontroller. So, without further ado, let's get started!
For this project, you will need:
- A PS/2 touchpad
- An Arduino microcontroller
- An H-bridge motor driver(Examples: DRV8833, L293D, L298N, etc)
- A DC motor with an attached rotary encoder
- A 5-volt supply(For the Arduino microcontroller)
- A DC power source for the motor(If it is intended to be operated at voltages >5-volts)
- A few male to male jumper wires
Step 1: Program the Microcontroller
You can get all the firmware resources, including the Arduino code and the required libraries from here.
Step 2: Connect the Microcontroller to the Motor Driver
Connect the motor driver's +ve input to the 5-volt pin or an external supply if you are using a larger motor. Connect the GND of the motor driver to the GND of the microcontroller(And the GND of the external supply, if used). Make the following connections between the microcontroller and the motor driver:
D9 - IN1
D10 - IN2
A lot of motor drivers have an 'enable' pin(EN) that needs to be connected to the +ve of the logic voltage. If yours has such a pin, connect it to the 5-volt pin of the microcontroller.
Step 3: Connect the Motor to the Motor Driver and the Microcontroller
Check the underside of the PCB attached to the motor showing the pin labels of the connector.
Connect the pins M1 and M2 to the output pins marked OUT1 and OUT2 of the motor driver.
Connect the GND pin to the GND of the Arduino microcontroller and the VCC pin to the 5-volt pin of the Arduino microcontroller.
Make the following connections between the encoder and the microcontroller:
C1 -> D2
C2 -> D3
If you wish to change the pins of the microcontroller to be connected to the encoder, make sure that the ones you are using are interrupt pins.
Step 4: Figure Out the Connections of the Touchpad
If you have a Synaptics touchpad like the above one, the pad 'T22' is +5V(VCC), 'T10' is 'Clock', 'T11' is 'Data' and 'T23' is 'GND'. You can also solder the 'GND' wire to a large exposed copper as shown above.
Click on the above image to know more. If you have a different touchpad, try searching for its part number on the internet with 'pinouts'.
Step 5: Connect the Touchpad to the Microcontroller
Make the following connections between the touchpad and the microcontroller:
VCC -> 5-V
GND -> GND
Clock -> D6
Data -> D5
Step 6: Mount the Motor on a Stand
Though this step is optional, this can help prevent the motor from moving around while rotating.
Step 7: Add a Position Marker to the Motor
You can use something like a wheel, a gear, a shaft attachment, even a piece of tape to see the movement of the motor.
Step 8: Power Up the Setup and Test the Controls
Check if your setup is working in the same way as shown in the video.
Start with sliding the finger slowly for a short distance in any direction. If the motor keeps on rotating for a long time then reverse the polarity of the motor's wires.
Step 9: Try Adding More to the Project
The microcontroller is using only a single axis of movement of the finger to control the motor. Why not try adding another motor and control both of them together, one with the horizontal and the other with the vertical movement of the finger. You can also try and make a touchpad-controlled vehicle with the help of these motors. Whatever you do, all the best!