Introduction: Arduino Controlled USB Trackpad

Picture of Arduino Controlled USB Trackpad

Every time a new raspberry pi comes out I take a look at the specs and think to myself "I really want to make a laptop out of that" but one issue always arises and that is that I can never find a stand alone USB trackpad for the laptop. So in this project, we will be salvaging a trackpad from an old broken laptop and converting it to USB device using an Arduino pro micro.

Step 1: Parts

Picture of Parts

The parts needed for this project are really simple, we will need a trackpad from an old laptop, an Arduino micro and some wire. Unfortunately, there are only a few flavors of Arduino that we can use, these are the Arduino micro, pro micro and Leonardo as these can be programmed to show up as HIDs (human interface devices) meaning they can show up on the computer as a mouse or keyboard. This is something the Arduino Uno can't do.
You can get the Arduino pro micro here: Here
As for the trackpad if you would rather buy one it can be found here: Here

Step 2: Why Does This Work

Picture of Why Does This Work

So the reason we can interface a trackpad with an Arduino is because most older laptops trackpads communicated with the computer through a PS/2 interface meaning the trackpad circuit has PS/2 outputs which are data and clock, this data is then read by the Arduino and converted into data that can be sent to the computer through the USB interface. Now I have to note that not all laptop trackpads are the same, pretty much all of the older laptops use a PS/2 interface but some newer ones use USB interface instead of the PS/2 interface. If you manage to find one of these USB trackpads instead of the PS/2 one you could just google the name of the trackpad and find the USB pinout and plug it into a USB computer and it will work. However, for this project we will be using the more common PS/2 trackpad and using an Arduino to make it into a USB mouse.

Step 3: Wiring

Picture of Wiring

The wiring for this project is pretty easy all we need to do is find 4 solder pads on our trackpad. These are pretty easy to find as they are labeled T10 (data), T11 (clock) and T20 and the ground connection is just a large exposed metal plane. We need to carefully solder a wire to each of these pads and then connect them to their corresponding Arduino pins.

  • T10 connects to pin 10 on the Arduino micro
  • T11 connects to pin 9 on the Arduino micro
  • T20 connects to 5v on the Arduino micro
  • The ground plane connects to ground on the Arduino micro

After you have soldered wires to the pads on the trackpad it's crucial that you don't put any pressure on these pads, even the slightest pressure on the pads can completely pull them off and make your trackpad useless. Its best to cover your connection with hot glue after you've soldered it.

Step 4: Installing Some Libraries

For this project we will need to install two libraries into the Arduino IDE, these libraries are:

Download them, open your Arduino IDE's library file and drop them in. The PS/2 library is used to get the data from the trackpad and the Mouse library allows us to take that data and turn it into mouse commands that the computer can read through the USB port.

Step 5: The Code

Picture of The Code

Now that we have the libraries installed we can upload our code to the Arduino, the code can be found below however I must note that the code will not upload or compile unless the board selected under tools is the Arduino micro or Leonardo so keep that in mind if you get an error while compiling the code. Once the code is uploaded the Arduino should reboot as a HID device and show up on the computer as a mouse.

Step 6: Finish and Troubleshooting

So now when you touch the touchpad you should get some movement on your screen and since the Arduino is acting as a USB device you can plug it into any computer and it will instantly boot up as a USB mouse regardless of the operating system or computer type. Now if you don't want to go through the process of programming and wiring the Arduino you could just buy a PS/2 to USB converter, but I wouldn't recommend this as I've read that this messes with the data coming from the trackpad and can make it unusable plus by using an Arduino we can completely customise everything about the mouse to our preference like the speed of the mouse and what actions like double tapping and scrolling does, information on how you can completely customise yours can be found on the Arduino mouse page Here.

If your trackpad isn't sending data back it may be an easy fix, take a look at the back of trackpad and try to locate a part number you can then google this part number with the word pinout and it should show you where the data, clock and 5-volt pins are.

Thanks so much for reading as always if you have any questions please leave them in the comments and I'll try my best to get back to you.

Comments

illumation_ (author)2017-11-09

Nice, thanks for sharing. Just a note, library links are swapped.

falias (author)2017-09-16

Hi,

my Arduino crashes because of a small error in your code.

You define the array msval with a length of 2 but you store 3 values in it.

int msval[3]; // edited

After that it worked flawlessly. Thank you so much!

Collie147 (author)2017-08-02

I used a different library, got it to work much more like a track pad rather that a directional scroller. Exactly the same hardware setup.

/*

* PSMouse Library - http://github.com/jazzycamel/PS2Mouse

* Script adapted by Collie147 from example - added Mouse.h and press/release functions

*/

#include "PS2Mouse.h"

#include "Mouse.h"

PS2Mouse PS2mouse(9,10)

void setup(){

Mouse.begin();

PS2mouse.begin();

}

void loop(){

uint8_t stat;

int x,y;

PS2mouse.getPosition(stat,x,y);

Mouse.move(x, -y, 0);

if (bitRead(stat, 0) == 1){

Mouse.press();

}

else{

Mouse.release();

}

}

This is really awesome!
Thank you so much for sharing!

You might need to add a delay(1000); after PS2mouse.begin();

AMIRSALARM (author)2017-07-21

hi

thanks for sharing.

could you explain these lines :

"

msval[0] = (((mstat2 & 0x10) << 8) | ((mxy & 0x0F) << 8) | mx );
msval[1] = (((mstat2 & 0x20) << 7) | ((mxy & 0xF0) << 4) | my );
msval[2] = int(mz);

"

and

if (msval[0] > 0 and msval[2] > 10)
{ repeatCnt++; }
else
{ repeatCnt = 0; }

if (repeatCnt > 2)
{
msval[0] = map(msval[0], 580, 5164, -1023, 1023);
msval[1] = map(msval[1], 1120, 5967, 1023, -1023);

NiftyNiffler (author)2017-07-17

Great idea! I haven't got arduino yet but is it a good kit?

Thanks,

Nifty

Which kit are you talking about?

The Arduino Starter kit R3. Want a link so you know what i'm talking about?

https://www.amazon.co.uk/Elegoo-Complete-Ultimate-TUTORIAL-controller/dp/B01IUY62RM/ref=sr_1_2?ie=UTF8&qid=1500465626&sr=8-2&keywords=arduino+starter+kit

About This Instructable

3,057views

77favorites

License:

Bio: I'm a 18-year-old high school student, I love engineering, film production, design and everything in between.
More by electronics for everyone:Raspberry Pi and Arduino LaptopArduino Controlled USB TrackpadEmergency Keyring Phone Charger
Add instructable to: