A Cool Laptop Touchpad Hack for Arduino Projects!
by KushagraK7 in Circuits > Arduino
6323 Views, 26 Favorites, 0 Comments
A Cool Laptop Touchpad Hack for Arduino Projects!
A while back, when I was tinkering around with a PS/2 touchpad with an Arduino microcontroller, I found out that two of its onboard connections can be used as digital inputs. In this Instructable, let's learn how we can utilize a PS/2 touchpad's additional digital inputs to use in our Arduino projects. Let's get started!
Watch the Video
Watch the video to get a better understanding of the project, know about the difficulties and get some tips.
Get All the Parts and Components
For this project, you will require:
- A PS/2 touchpad(A Synaptics one is recommended as it is known and tested.)
- An Arduino microcontroller to interface with the touchpad(UNO, Leonardo, Nano, Micro, etc).
- A 5-volt DC power source.
- Some male to male jumper wires.
- At least 6 wires(For soldering on the touchpad or the ribbon cable.)
- Solder wire.
- Soldering iron.
- Solder flux(You can get away without it but it makes solder jobs better.)
- Two pushbuttons(For button LED demo code.)
- A rotary encoder. (Optional, for rotary encoder demo code.)
Get the PS2 Library for Arduino
Download the ps2 library from here. Move the downloaded folder to the desktop as it will be easier to find. Open the Arduino IDE and click Sketch>Include Library>Add .ZIP Library... and then select the ps2 folder from the desktop. The library will be included and you now be able to use the ps2 library.
Identify the Solder Pads on the Touchpad
First, check online for the datasheet of the touchpad with the help of its part number. You need to find the 'Clock', 'Data', 'Vcc', and 'Gnd' connection pads.
Generally, the following pads correspond to the respective pins:
- 22 ~> +5-volts(Vcc)
- 23 ~> Ground(Gnd)
- 10 ~> Clock
- 11 ~> Data
Connect Wires to the Identified Solder Pads
Click on the pictures to know more.
You can either solder wires directly to the solder pads or go a bit further and modify an appropriate ribbon cable as shown in the picture to make the wiring cleaner. I just attached male jumper wires to the touchpad since the onboard ribbon cable connector was large enough.
Program the Arduino Microcontroller
Program the Arduino microcontroller with the attached code.
Downloads
Connect the Touchpad to the Arduino Board
Take each wire connected to the respective solder pads on the touchpad and make the following connections with the Arduino board:
- 22 ~> 5V
- 23 ~> GND
- 10 ~> A0
- 11 ~> A1
Connect the Arduino Board to the Computer and Open the Serial Monitor
First, determine which solder pads on the touchpad are connected to the onboard ribbon cable connector(Look for copper traces connecting the pads and the pins of the ribbon cable connector.), the ones we are looking after will be among these.
Take a male jumper wire and connect one of its ends to the 'GND' header of the Arduino board. Connect the Arduino board to the computer and turn on the serial monitor in the Arduino IDE. On opening the Serial monitor, if nothing shows up, check if you have selected the right board, recheck the wiring connections and restart the touchpad by disconnecting and reconnecting the touchpad's +5-volt wire. If everything was done properly, the serial monitor should start to show a row of numbers. The first row showing the number 8 is important for us.
After doing all of this, connect the loose jumper wire to each of the solder pads, probably between 2 and 9 which are connected to the ribbon cable connector. Among these, there will be two pads which on being touched with the loose jumper wire, will cause the number on the serial monitor to change from 8 to either 9 or 10. These are the solder pads we are looking for. Label the pad changing the number to 9 as 'InA' and the one changing the number to 'InB'. The touchpad I used had the pads 6 and 7 which caused the change in the number on the serial monitor.
Check one more thing, on connecting both of these solder pads to GND simultaneously will cause the number on the serial monitor to change to 11.
Connect Additional Wires to the Touchpad
Solder a wire each on the solder pads identified in the previous step. If you were using a modified ribbon cable, then find which pin of the cable connector is connected to the required solder pads and attach wires on the corresponding conductors of the ribbon cable.
Program the Arduino Microcontroller With the Demo Code
The following code uses the two additional pins of the touchpad we discovered earlier as digital inputs, each connected to ground pin through a pushbutton.
Downloads
Test the Setup
After programming the Arduino microcontroller, connect the pad 'A' to GND either with a wire or a pushbutton momentarily, this would cause the LED connected to pin D13 of the Arduino board to light up. Then, do the same with the pad 'B', this would cause the LED to turn off.
Add a Rotary Encoder
If you just wanted to use this hack to add extra digital inputs to your touchpad, then it's done! But if you want to take it further, you can even add a rotary encoder to the touchpad. Here, I have used a stepper motor as a rotary encoder.
Program the Arduino Board
Program the microcontroller with the given code to test the touchpad with the rotary encoder. The code allows us to adjust the brightness of an LED connected to pin D9 of the Arduino board using the rotary encoder or by sliding the finger along the x-axis of the touchpad.
Connect the Rotary Encoder's Outputs to the Digital Inputs of the Touchpad
Click on each picture to know more.
Connect the two output pins of the rotary encoder to 'InA' and 'InB' of the touchpad.
Connect the Rotary Encoder and Touchpad to Power
Connect the +ve terminal of the encoder ad the touchpad to the +5-volt header of the Arduino board and the -ve terminal to the 'GND' header of the Arduino board.
Click on the pictures to know more.
Connect the Touchpad's Communication Wires to the Arduino Board
Connect the 'Clock' and 'Data' wires of the touchpad to the headers 'A0' and 'A1' of the Arduino board.
Connect the Setup to Power and Test the Encoder
Since the communication between the Arduino microcontroller and the touchpad adds some delay, the rotary encoder can't be operated reliably at high speeds.
What Are You Going to Do?
So now that we know how to add two additional digital inputs for Arduino touchpad projects, what are you going to do with this hack? If you make this project, try sharing it with the community by clicking on 'I Made It!'.
All the best!