It only cost $30, and now that the software is finished, can be recreated very easily, would anyone be interested in a tutorial on how to make one?
Moderators: arduwino, adafruit

timv wrote:But what would really be hip would be for the Arduino to interface as though it was a PS/2 mouse. There's a lot of info related to this, but I did a quick search and didn't see anyone who had done exactly that.

int ledPinX = 9;
int ledPinY = 10;
int xaccPin = 7;
int yaccPin = 6;
int value = 0;
int accel = 0;
char sign = ' ';
int leftPin = 4;
int rightPin = 3;
int timer = 0;
int count = 0;
int tiltX = 0;
int tiltY = 0;
int axis = 0;
int canClick = 1;
void setup() {
beginSerial(9600); // Sets the baud rate to 9600
pinMode(ledPinX, OUTPUT);
pinMode(xaccPin, INPUT);
pinMode(yaccPin, INPUT);
}
int operateAcceleration(int time1) {
return abs(8 * (time1 / 10 - 500));
}
/* (void) readAccelerometer
* procedure to read the sensor, calculate
* acceleration and represent the value
*/
void readAcceleration(){
/*
START X
*/
axis = xaccPin;
timer = 0;
count = 0;
value = digitalRead(axis);
while(value == HIGH) { // Loop until pin reads a low
value = digitalRead(axis);
}
while(value == LOW) { // Loop until pin reads a high
value = digitalRead(axis);
}
while(value == HIGH) { // Loop until pin reads a low and count
value = digitalRead(axis);
count+=1;
}
timer = count * 18; //calculate the time in miliseconds
accel = operateAcceleration(timer);
//Represent acceleration over serial port
tiltX = (accel - 8000) / 70;
while (tiltX > 100){tiltX-=1;}
while (tiltX < 0){tiltX+=1;}
analogWrite(ledPinX, (tiltX));
Serial.print(tiltX);
Serial.print(" ");
/*
START Y
*/
axis = yaccPin;
timer = 0;
count = 0;
value = digitalRead(axis);
while(value == HIGH) { // Loop until pin reads a low
value = digitalRead(axis);
}
while(value == LOW) { // Loop until pin reads a high
value = digitalRead(axis);
}
while(value == HIGH) { // Loop until pin reads a low and count
value = digitalRead(axis);
count+=1;
}
timer = count * 18; //calculate the time in miliseconds
accel = operateAcceleration(timer);
//Represent acceleration over serial port
tiltY = (accel - 8000) / 70 + 35;
while (tiltY > 100){tiltY-=1;}
while (tiltY < 0){tiltY+=1;}
analogWrite(ledPinY, tiltY);
Serial.println(tiltY);
}
void loop() {
if (Serial.read() != -1){
readAcceleration(); //reads and represents acceleration
delay(49);
}
if (digitalRead(leftPin) == HIGH && canClick == 1){
delay(3);
if (digitalRead(leftPin) == HIGH){
Serial.println("left");
canClick = 0;
}
}
else if (digitalRead(rightPin) == HIGH && canClick == 1){
delay(3);
if (digitalRead(rightPin) == HIGH){
Serial.println("right");
canClick = 0;
}
}
if (digitalRead(leftPin) == LOW && digitalRead(rightPin) == LOW){
delay(3);
if (digitalRead(leftPin) == LOW && digitalRead(rightPin) ==
LOW){canClick = 1;}
}
}Return to Arduino Starter Pack
Users browsing this forum: No registered users and 0 guests