Академический Документы
Профессиональный Документы
Культура Документы
Art
Craft
Food
Games
Green
Home
Kids
Life
Music
Offbeat
Outdoors
Pets
Photo
Ride
Science
Tech
Table of Contents
Arduino + Laptop Touchpad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
http://www.instructables.com/id/Arduino-Laptop-Touchpad/
http://www.instructables.com/id/Arduino-Laptop-Touchpad/
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 Pnkk
// 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);
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();
// 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);
http://www.instructables.com/id/Arduino-Laptop-Touchpad/
lc.setLed(0,7,6,true);
lc.setLed(0,7,7,true);
}
// some delay so one can see the leds properly
delay(100);
}
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:
// Arduino + Laptop TouchPad. iPod style gesture
//
// http://Metku.net
// Jani Pnkk
// 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
http://www.instructables.com/id/Arduino-Laptop-Touchpad/
http://www.instructables.com/id/Arduino-Laptop-Touchpad/
Related Instructables
The 5$
Karduinoss pad
by buZztiaan
Turn a Trackpad
From a Broken
Laptop into a
PS/2 Mouse by
cheft
How to make a
DIY iPhone /
iPod Touch
Stylus by TTSDA
How To
Connect a PS/2
Keyboard to the
iPhone by awgh
Mousing Atop
Laptop by
TimAnderson
Knit Touchpad
by Plusea
Comments
7 comments
Add Comment
timcaird says:
japala says:
bears0 says:
you should make your own operating system with a little lcd display, maybe a calculator or some type of game.
jam BD says:
Very neat =)
japala says:
Questions? :)
madmanmoe64 says:
japala says:
http://www.instructables.com/id/Arduino-Laptop-Touchpad/
http://www.instructables.com/id/Arduino-Laptop-Touchpad/