Professional Documents
Culture Documents
Arduino Laptop Touchpad PDF
Arduino Laptop Touchpad PDF
Table of Contents
Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
http://www.instructables.com/id/Arduino-Laptop-Touchpad/
Intro: Arduino + Laptop Touchpad
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.
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.
http://www.instructables.com/id/Arduino-Laptop-Touchpad/
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.
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.
----------------------
The code:
#include "PS2Mouse.h"
#include "LedControl.h"
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);
http://www.instructables.com/id/Arduino-Laptop-Touchpad/
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();
// 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);
http://www.instructables.com/id/Arduino-Laptop-Touchpad/
lc.setLed(0,7,6,true);
lc.setLed(0,7,7,true);
}
Image Notes
1. MAX7219 Led Driver installed behind the led matrix.
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:
#include "PS2Mouse.h"
#include "LedControl.h"
http://www.instructables.com/id/Arduino-Laptop-Touchpad/
LedControl lc=LedControl(12,11,10,1); // forum pin outs
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);
--------------
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.
Related Instructables
Comments
7 comments Add Comment
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.
I have seen the touch screen digitisers for sale on ebay etc.and they look very simple, only four wires.
I assumed it was just V+, V- and two analogue readings which would give you the X and Y positions?
Do you know much about these? or if it is possible to interface with it on it's own?
thanks,
- Tom
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...
http://www.instructables.com/id/Arduino-Laptop-Touchpad/
http://www.instructables.com/id/Arduino-Laptop-Touchpad/