loading
Yes, this is more or less your average touchpad that one can find from inside a laptop. This model, like majority of touchpads out there operates with PS/2 standard. This means that it can be directly plugged in to a PS/2 connector and with proper drivers, function as a mouse.

As it happens the PS/2 communication is not that difficult to achieve with an Arduino board. Kristopher has written an Arduino/Wiring library that offers all the functionality that we need at this point.

I will be using the MAX7219 Led Controller too and for this one can use LedControl library , written by Eberhard Fahle.

Step 1: Putting the Touchpad Together

I happened to find this TouchPad from inside a dead Fujitsu Siemens laptop. Model number for the pad is ALPS JCI-S1S. These kind of modules are easy to source also from ebay etc.

Ground and supply voltage pins are usually easy to guess just by looking at the circuit board but the data and clock pins were found by just pure trial and error method.

As the flexible cable is not the best suited for use with Arduino, I soldered better wires for the pins. Hot glue was used to make the connection more secure.


Step 2: Coding - Part I

Here are both the TouchPad and the 8x8 Ledmatrix hooked up to Arduino. Touchpad uses the 5 and 6 pins on Arduino and the MAX7219 utilizes the pins 10, 11 and 12. What goes were can be easy seen inside the code.

First test - Direction and buttons


TouchPad reports the movement of the finger. One gets a pair of coordinates that indicated the amount of movement and the direction from the last position. For example -12, 2 would mean a swipe towards 10 o'clock and the X-axis movement being faster.

As it turns out, even the tap functionality works perfectly.

----------------------

The code:

// Arduino + Laptop TouchPad. Basic functionality
//
// http://Metku.net
// Jani Pönkkö
// 23.07.2009


#include "PS2Mouse.h"
#include "LedControl.h"

#define MDATA 5 // touchpad ps/2 data pin
#define MCLK 6 // touchpad ps/2 clock pin
#define SENSITIVITY 5 // amount of movement needed to get a reaction


LedControl lc=LedControl(12,11,10,1); // forum pin outs

PS2Mouse mouse_one(MCLK, MDATA, REMOTE);

void setup()
{
  lc.setIntensity(0,8);
  lc.shutdown(0,false); // need to take MAX out of shutdown
  lc.clearDisplay(0);
  delay(10);

  Serial.begin(115200);
  mouse_one.initialize();
  mouse_one.set_scaling_1_1();
}

void loop()
{
  int data[2];
  mouse_one.report(data);
  Serial.print(data[0]); // Status Byte
  Serial.print(":");
  Serial.print(data[1]); // X Movement Data
  Serial.print(",");
  Serial.print(data[2]); // Y Movement Data
  Serial.println();

  // draw the initial box to the center
  lc.clearDisplay(0);

  // if no movement, light up the center block
  if(data[1]==0 && data[2]==0)
  {
    lc.setLed(0,3,3,true);
    lc.setLed(0,3,4,true);
    lc.setLed(0,4,3,true);
    lc.setLed(0,4,4,true);
  }


  // X-movement
  if(data[1]>SENSITIVITY)
  {
    lc.setLed(0,1,3,true);
    lc.setLed(0,1,4,true);
    lc.setLed(0,2,3,true);
    lc.setLed(0,2,4,true);
  }
  if(data[1]<-SENSITIVITY)
  {
    lc.setLed(0,5,3,true);
    lc.setLed(0,5,4,true);
    lc.setLed(0,6,3,true);
    lc.setLed(0,6,4,true);
  }


  // Y-movement
  if(data[2]>SENSITIVITY)
  {
    lc.setLed(0,3,1,true);
    lc.setLed(0,3,2,true);
    lc.setLed(0,4,1,true);
    lc.setLed(0,4,2,true);
  }
   if(data[2]<-SENSITIVITY)
  {
    lc.setLed(0,3,5,true);
    lc.setLed(0,3,6,true);
    lc.setLed(0,4,5,true);
    lc.setLed(0,4,6,true);
  }


  // Left button
  if(data[0]==10)
  {
    lc.setLed(0,0,6,true);
    lc.setLed(0,0,7,true);
    lc.setLed(0,1,6,true);
    lc.setLed(0,1,7,true);
  }

   // Middle button
  if(data[0]==12)
  {
    lc.setLed(0,3,6,true);
    lc.setLed(0,3,7,true);
    lc.setLed(0,4,6,true);
    lc.setLed(0,4,7,true);
  }

  // Right button
  if(data[0]==9)
  {
    lc.setLed(0,6,6,true);
    lc.setLed(0,6,7,true);
    lc.setLed(0,7,6,true);
    lc.setLed(0,7,7,true);
  }

  // some delay so one can see the leds properly
  delay(100);

}

Step 3: Coding - Part II

Second test - iPod style gesture



I adapted the code a bit so it could react to a iPod style circular gesture. This could be use to speed up a motor, increase volume, turn a servo etc... hmm... a game of safe cracker perhaps... ;)

The code may not be the highest quality but it should give you the idea what is happening.

----------------------------
The code:


// Arduino + Laptop TouchPad. iPod style gesture
//
// http://Metku.net
// Jani Pönkkö
// 23.07.2009


#include "PS2Mouse.h"
#include "LedControl.h"

#define MDATA 5 // touchpad ps/2 data pin
#define MCLK 6 // touchpad ps/2 clock pin
#define SENSITIVITY 5 // amount of movement needed to get a reaction

LedControl lc=LedControl(12,11,10,1); // forum pin outs

PS2Mouse mouse_one(MCLK, MDATA, REMOTE);

int value;
int i;
int l;
int dir; // indicates where user is "turning" the dial

void setup()
{
   lc.setIntensity(0,8);
   lc.shutdown(0,false); // need to take MAX out of shutdown
   lc.clearDisplay(0); 
   delay(10);

   Serial.begin(115200);
  mouse_one.initialize();
   mouse_one.set_scaling_1_1();

   value=7;
}

void loop()
{
   int data[2];

   mouse_one.report(data);

   // handle the leds. Made this way to combat flickering...
   for(i=7;i>=0;i--)
   {
    if(value<=i)
    {
      for(l=0;l<=7;l++)
      lc.setLed(0,l,i,true);
    }
    else
    {
      for(l=0;l<=7;l++)
      lc.setLed(0,l,i,false);
   }
}


// Moving to the right
if(data[1]>SENSITIVITY)
{
   if(dir==0) // direction is counter clockwise
   dir=-1; // dec
}

 // Moving to the left
if(data[1]<-SENSITIVITY)
{
  if(dir==0) // direction is clockwise
  dir=1; // incrementation
}

// top of the "turn"
if(data[2]>SENSITIVITY)
{
   dir=0; // we got the start indication (top part of the circle)
}

// bottom of the "turn"
if(data[2]<-SENSITIVITY)
{
   if(dir==-1) // we got counter clockwise turn
   {
     if(value>0)
    {
      value=value-1;
      dir=-2; // reset the value to something non-valid
    }
  }
  if(dir==1)
  {
     if(value<7)
    {
       value=value+1;
      dir=-2; // reset the value to something non-valid
    }
  }
}

// some delay so one can see the leds properl
delay(100);


}

--------------

I hope that you found this short tutorial useful. If you ever find this material useful, please, share your findings and projects with us. Either by registering here to Allthemods.com or by visiting Metku.net . Thanks.

 

<p>Hi,</p><p>I'm unable to find the datasheet/specs of my touchpad so I don't know the pinout...</p><p>Can someone tell me how to do so with a multimeter ?</p><p>Synaptics TM2997 / 920-002811-01rev2</p><p>Thanks</p>
<p>where do I plug in the cables on the arduin. Please help me</p>
<p>Thank you! This helped me out a lot, I connected the touchpad and it works!</p><p>The only thing that bothers me, is that when I swipe left or right, and keep my finger there, the code always goes back to the center (so 0,0).</p><p>This is why the second code (iPod Gesture) doesn't seem to work. I can't figure out how to fix it, have you got any ideas?</p>
Sorry for the data delay.<br><br>I'v a touch pad from a HP Pavilion dv600, but it have only 4 connections. It is possibly a chassi ground?<br><br>Thanks
<p>maybe it is usb- based</p>
mantap sekali
<p>Are there any possible applications with out an led matrix like possibly controlling servos or motors.</p>
Hi, I've got this touchpad, I'm a bit confused about the wires, from the touchpad itself it comes like a dozen of wires, but from the buttons board it come 6 wires. wich one I have to use?
does the arduino support multitouch? and how much does it cost? because the computer engineer of our school is going to bring me one out of an old laptop?
Or maby the NC wire is not present?<br><br>Sorry for the bad english.
cool, i have an old laptop touchpad and tried connecting it io a usb port, it worked but i forgot which pins go where and didn't even use an arduino, so now i am going to do this with the pad <br>cool ible
i have a question if u have 5 pins coming from the mouse and two goes for power(and ground) and two goes for data where does one go (the nc or the data or the clock) i'm sorry i couldn't see it in the code as i'm just learning the arduino and i'm getting a friend who does c coding to help me later on in my project
See this first: http://pragprog.com/magazines/2010-07/meet-the-arduino<br><br>In the code this block is important!:<br>#define MDATA 5 // touchpad ps/2 data pin<br>#define MCLK 6 // touchpad ps/2 clock pin<br><br>So, the wire from mouse labeled as Data goes to digital I/O pin 5 on Arduino (top row). The wire named Clock goes to Arduino's Digital I/O pin 6.<br><br>Wire labeled +5v goes to bottom row, marked as power/Power Supply. There the pin marked as 5v. The two wires market as GND coming from mouse are connected to the pin Gnd in the power section on Arduino. The wire marked as NC doesn't need to be connected anywhere, just leave it be. <br><br>Hope this helps. :)
thanks man this helped a lot but i have one more question when u tap the pad does this send a different signal to the arduino from when u use the left button to click because i have something like a menu selection in mind like the left and right buttons to scroll and the tap to enter
Loving the Arduino-touchpad combo :) How easy would it be to adapt the trackpad for use with a PC? Could you output the Arduino to USB for input to the PC?
Well, if the PC already has a PS2 connector, you can just plug the touchpad in and it would work. And yes, you could route the data from the Arduino to PC via the USB port if needed. With a simple program on PC side one could control the mouse, alter the volume etc. with this thing. <br><br>Arduino can not be used as an HID device. It can't be operated as a mouse or a keyboard on its own. If you swap the Arduino for example to a Teensy, you could just plug the device to the USB port and the computer would recognize it as a mouse without any additional software on the PC side.
you should make your own operating system with a little lcd display, maybe a calculator or some type of game.
Very neat =)
Questions? :)
Read through this quickly (don't use arduino so didn't understand much) and I was wondering if it is possible to use this without the attached hardware.<br><br>I have seen the touch screen digitisers for sale on ebay etc.and they look very simple, only four wires.<br>I assumed it was just V+, V- and two analogue readings which would give you the X and Y positions?<br><br>Do you know much about these? or if it is possible to interface with it on it's own?<br><br>This would allow me to program my own gestures etc.<br><br>thanks, <br><br>- Tom
I believe this link gives a good idea about the technology:<br>http://www.touchscreenguide.com/touchscreen/res.html#4w<br><br>It would be fairly easy to use these touchscreen films with microcontrollers that have ADC in them. I haven't done it myself but there are tons of material in the net on how to do this. But then again, it should not be impossible to use the signal the film gives with purely analog circuitry too. Just to check which half of the film was pressed to see if the user selected the left or the right side etc... some comparators, opamps...

About This Instructable

55,306views

170favorites

License:

More by japala:Arduino + Laptop Touchpad Animating Multilayered Engravings 
Add instructable to: