DIY USB mouse from the accelerometer and USBAsp programmer
Actually, I got almost such a mouse here, as in the photo. (Well, almost almost =))
I took as my basis my old USBAsp programmer for AVR microcontrollers and the ADXL322JCP accelerometer .
This accelerometer was selected for the following reasons:
- measures acceleration up to 2g
- was available in the store
- was one of the cheapest (more precisely, the cheapest)
Due to the small range of measured accelerations, this accelerometer allows you to determine what position the chip is in.
Well and accordingly it turns out something like measuring the angle of inclination. At what degree the mouse bent, the cursor will rush at that speed. (at least for me) :) It can simply deviate along the slope. Like a mouse in the picture.
To begin with, I used the legs with the ADC that were not used in the programmer, and connected a variable resistor to them for the test. I played around a bit, even made it work like a USB mouse thanks to this article and the AVR-USB library . There actually is a ready-made demo version of an example of a USB mouse device, which when connected makes the cursor move in a circle. Without hesitation, I tuned the ADC, set the rarest interrupt, changed a few lines of code in the finished example. I requested it. And everything worked the first time. =)
It turned out fun, you turn the resistor, and the mouse cursor runs to here. Well, I think the matter remains the most difficult, to solder to the LFCSP case (4 x 4 x 1.45 mm !!! and as many as 16 conclusions !!! of which, essentially, I need 5 current).
After an hour of soldering and reasoning about how best to arrange, I finally soldered, connected, flashed and turned it on. And lo and behold, everything started working the first time, first one channel, then connected the second channel. Everything works. You bend to one side, the cursor ran to the left, the other, the cursor ran back, it also runs up / down, fun. =) Actually the idea is not new. I found similar on the Internet, but on PICs and with a COM port. So I thought what I was worse. =) There is a video => http://www.uchobby.com/index.php/2007/10/27/accelerometer-based-mouse
Well, the video from the Analog Devices site itself, where they already present the finished product: Analog Devices video
Sell this thing sort of like here: