0

Tilt sensing mouse!!!!
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Tilt sensing mouse!!!!

by magician13134 on Sun Jan 06, 2008 10:21 pm

I just finished up my tilt-sensing mouse using the Arduino! :)
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?
magician13134
 
Posts: 1119
Joined: Wed Jun 13, 2007 9:17 am
Location: Ann Arbor

by timv on Sun Jan 06, 2008 11:10 pm

Definitely!
timv
 
Posts: 82
Joined: Thu Nov 01, 2007 4:13 pm

by magician13134 on Tue Jan 08, 2008 7:46 am

Cool, well right now, I'm trying to make a circuit board for this (it's on the tiny breadboard right now...) And I made a little board type thing in MsPaint, but can someone turn this into an Eagle file for me? My skills there are very poor.

Image

Image

Image



My circuit may be a little confusing, but I plan to put some header pins on the bottom, top, and right so it'll plug into my Protoshield.

The pins I'm using on the bottom are 5V and 3V (in the photographs I'm using ground too, but I'm using that from the right in this circuit)

The grey is either a jumper, component, or resistor
Last edited by magician13134 on Thu Feb 21, 2008 7:09 pm, edited 1 time in total.
magician13134
 
Posts: 1119
Joined: Wed Jun 13, 2007 9:17 am
Location: Ann Arbor

by magician13134 on Wed Jan 09, 2008 9:15 pm

Ok, I got a circuit, but I'm having some troubles with the toner transferring, the circuit is really exactly two inches tall, and my boards are 2"x2", so I can't get it on without cutting off bits of it. Would anyone be willing to make a quick home-etch of this board for me? You wouldn't even have to drill the holes or etch if you don't want. I'll attach the image, it's 300dpi, and 4x6 to make it easier, you can trim it if you want.

[Better board on down]

Also, here's all the source code you need. The 'accelerometer' folder is the Arduino sketch, 'tiltMouse.exe' interprets the Arduino's data. 'tiltMouse.au3' is the source code for that program, the dll is also needed. (I did NOT write the dll, so I cannot take credit for it)
http://www.magicsoftinc.com/tiltMouse.zip
Last edited by magician13134 on Thu Jan 10, 2008 7:35 pm, edited 1 time in total.
magician13134
 
Posts: 1119
Joined: Wed Jun 13, 2007 9:17 am
Location: Ann Arbor

by timv on Thu Jan 10, 2008 7:25 am

I'm not sure what state my laser printer is in right now (skipping lines sometimes, maybe ready for a new cartridge) but I'll try to give it a shot over the weekend. I bought some etching liquid and copper-clad boards years back and just never got around to trying to learn how to do it. I've been getting curious again reading the posts here.

But what's this ".dll" business here? What am I supposed to do with this on an Ubuntu Linux box? Open source, man, not mystery binary files. And why are AVR hackers so totally in love with Microsoft anyway? Is it Bill Gates's glasses? Steve Ballmer's shiny bald head? I don't get it. :-)
timv
 
Posts: 82
Joined: Thu Nov 01, 2007 4:13 pm

by magician13134 on Thu Jan 10, 2008 7:38 am

Ah, I took an hour or so last night and finally got one etched really well (stupid logo is backwards *grumble*) So that won't be necessary. Feel free to still make one for yourself though, the only problem with this single sided board is soldering in the header pins, they're supposed to be on the other side... but I'm sure it'll be possible.

And sorry about the dll, like I said, I didn't write it. The just wasn't any serial support built in to the language I was using, and I don't know any other languages well enough to do this...
magician13134
 
Posts: 1119
Joined: Wed Jun 13, 2007 9:17 am
Location: Ann Arbor

by timv on Thu Jan 10, 2008 11:36 am

Congrats on getting the board etched. I'll see how things go this weekend, and maybe try it if I get the chance. So is this using the Radio Shack accelerometer that you posted about on arduino.cc?

I see that a retail location about a mile away from me is listing them in stock. Maybe at lunchtime...

And don't sweat the .dll business. I was just venting. That had been building for a while.

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.
timv
 
Posts: 82
Joined: Thu Nov 01, 2007 4:13 pm

by magician13134 on Thu Jan 10, 2008 5:27 pm

Do not etch this board image
Here's more information why: http://www.ladyada.net/forums/viewtopic.php?p=21784#21784

How hard could that be? Just attach two output pins to the photo detectors in an old mouse, and two for the buttons, only problem is that requires another board (unless you were thinking of putting all the code on the Arduino). Either way, I have several old mice, and I'll get right on it after tomorrow's physics test... and exams... and engineering fair... Uggh. I'm going to upload an updated board later for those of you interested in making one to use.

Oh, and yes this is the accelerometer from Radioshack. You can get it cheaper from parallax, but then there's shipping

One more question is what size drill bit do you guys use when making PCBs? I have a 1/16, but I'm thinking about getting some 1/32s... Any thoughts there?

Here's the old board, I'm pretty pleased with how it came out (this is a top view)
Image


Alright, here's a better board for you guys, sorry for the thing that doesn't even resemble a schematic, you should be smart enough to figure out my scribbles are resistors, though :wink:
Image
Last edited by magician13134 on Thu Jan 10, 2008 11:22 pm, edited 1 time in total.
magician13134
 
Posts: 1119
Joined: Wed Jun 13, 2007 9:17 am
Location: Ann Arbor

by adafruit on Thu Jan 10, 2008 6:55 pm

sweet im totally posting this to the ladyada.net blog :)

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

by mtbf0 on Thu Jan 10, 2008 7:59 pm

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.


what about the avr-usb project that's the basis for ladyada's usbtinyisp? it provides an hid interface to the computer. i'm pretty sure that there are some people how have done this on the arduino. it eats a lot of cycles though, so i don't know how much time you'd have for dealing with the accelerometer and buttons.

my idea is a mouse glove. you could use the lilypad arduino from sparkfun. the lilypad accelerometer is cheaper than most modules. and buttons in the finger tips. of course, you couldn't type, but i can't type anyway.

but, what i mean is, uh, cool.
User avatar
mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am
Location: oakland ca

by Entropy on Thu Jan 10, 2008 9:43 pm

Easiest for the Arduino (and Boarduino) would be to emulate a serial mouse, since the Arduino's USB interface is via a USB-to-serial converter.

Windows support for serial mice can sometimes be a bit wacky though, not sure how well a serial mouse on a USB-to-serial interface would work, but it's the "path of least resistance" for a user of Arduino hardware.

The "right way" to do it would indeed be something like Objective Development's AVR-USB, or USBTiny. (USBTinyISP is based on a different codebase than AVR-USB.) ObjDev has some examples of emulated HID devices, so AVR-USB is probably the best place to start if you want to add a USB HID interface to the Arduino.

Note that if you're using the Arduino development environment (as opposed to Arduino/Arduino-compatible hardware combined with a standard AVR C development environment), implementing anything other than an emulated serial mouse is probably not going to be possible. If you use AVR-GCC, then you can base an implementation off of AVR-USB.

I think I'm going to have to stop at Unicorn Electronics to buy some Zeners and low-value resistors Saturday for my Boarduino... :)
Entropy
 
Posts: 472
Joined: Tue Jan 08, 2008 12:43 am
Location: Owego, NY USA

by magician13134 on Thu Jan 10, 2008 11:17 pm

Thanks for all the positive responses (and the blog! :o) I hate to say this, but I soldered up the board I made tonight and realized I had left in so glaring errors. So as of now, DO NOT ETCH THE BOARD I PROVIDED! The problem is, the headers on the top and bottom fit only the Arduino itself, whereas I have headers on the right trying to get grounded, but ground only exists there on the protoshield... I did some work with jumpers just to see if the circuit board worked otherwise, and I ended up getting very random jerking motions from the mouse in Windows, the buttons didn't work and it didn't move where/when you told it. So.... I would recommend only building it on breadboard as of now. The two pictures should be nice enough quality to see what I did, but if not, I'll be glad to post more information.

And once again, I ask (for the sake of anyone wanting to attempt this), could someone who knows anything about Eagle or a similar program design a layout that will fit the Arduino?
magician13134
 
Posts: 1119
Joined: Wed Jun 13, 2007 9:17 am
Location: Ann Arbor

by Entropy on Fri Jan 11, 2008 11:29 am

Unfortunately, while I have some skills with Eagle, I don't have an Arduino, just a Boarduino.

Just for reference, is this the Memsic 2125? (RS 276-029)

Sparkfun carries dual and triple axis accels on breakout boards in about the same price range.
Entropy
 
Posts: 472
Joined: Tue Jan 08, 2008 12:43 am
Location: Owego, NY USA

by magician13134 on Fri Jan 11, 2008 11:39 am

Yeah, it is the 2125



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



Ok, here's an updated image that should work with the Protoshield, if someone makes this, let us know how it goes, thanks!


Image
magician13134
 
Posts: 1119
Joined: Wed Jun 13, 2007 9:17 am
Location: Ann Arbor

by magician13134 on Sun Feb 10, 2008 6:33 pm

Sorry for the delay guys, but I finally got around to designing/etching/drilling/soldering and of course testing a new tilt mouse.

Here's everything you need to make this project:
Firstly you'll need these pieces:
    (1) Memsic 2125 Accelerometer (RS 276-029)
    (1)(Optional, but recommended) 8 pin DIP Socket (you'll need to cut off two pins to make it fit on the board)
    (2) Push buttons, normally open
    (2) 100ohm (or similar) resistors
    (2) 1kOhm (or similar) resistors
Next, you'll need to etch the circuit board, it ONLY works with the protoshield, sorry those of you who don't have that:
http://www.magicsoftinc.com/software/ti ... /final.gif
(that's 300dpi, it's only around 2"x2"!!!!)

Arduino code:
Code: Select all | TOGGLE FULL SIZE
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;}
}
}

Interpreter program:
http://www.magicsoftinc.com/software/ti ... tMouse.exe


How to use it:
    Make the circuit board
    Insert the accelerometer into the socket. (There are 6 pins then the board continues for another .1" or so, so place it with the pinless end pointing towards the buttons. It should take up all the space in the 8 pin socket)
    Write the code to the Arduino using the software from www.arduino.cc
    You can close that program once its written, it is no longer necessary
    Plug the circuit board into the protoshield into the Arduino into a computer
    Run tiltMouse.exe


Voila! That's it
magician13134
 
Posts: 1119
Joined: Wed Jun 13, 2007 9:17 am
Location: Ann Arbor

Please be positive and constructive with your questions and comments.