USB HID absolute pointing device using ATmega8 and a magnetometer

Tags: ATmega8, AVR, Hardware, Microcontroller, Programming, Python, USB

In last November, I finally finished my college! I’ve got a Bachelor’s Degree in Computer Science by UFRJ (Universidade Federal do Rio de Janeiro).

And for my senior project (or final graduating project, or TCC - Trabalho de Conclusão de Curso, or PFC - Projeto Final de Curso) I chose to build a USB device that could control the mouse pointer, using an AVR ATmega8 microcontroller and a magnetometer.

A magnetometer is a digital compass, something that can measure the magnetic field (in three dimensions). The idea is that the user holds the magnetometer and moves it around (actually, only the rotation is considered). When the magnetometer orientation changes, the measured 3D vector of the magnetic field also changes. Based on this vector, the microcontroller applies some math and moves the mouse pointer to some position at the screen.

In a nutshell, the device behaves like a Wiimote, but using a completely different technology. You just point the device to some direction, and the mouse pointer is moved to that position.

Since the microcontroller implements the USB HID class (using V-USB firmware-only USB implementation, by OBJECTIVE DEVELOPMENT Software GmbH (Wayback Machine)), it works straight away on any operating system without requiring any special driver. It has been successfully tested on Linux, Mac OS X and Windows. It was also tested on one Android device, but it did not support an absolute pointing device.

Links:

Videos:

Dispositivo apontador com interface USB usando magnetômetro (English subtitles available)

Moving the mouse pointer using head movements

USB Absolute Pointing Device implemented in ATmega8 using Magnetometer (work-in-progress video)

This project was challenging and very rewarding. It feels good to see it working after so many weeks staying awake during the night developing and debugging it.

Trivia: the idea for this project was inspired by Marcin Wichary speak/demonstration at Google I/O 2011: The Secrets of Google Pac-Man: A Game Show

comments powered by Disqus