accelball: Python + N95 accelerometer demo

So, today, I built a small application to demonstrate the use of the accelerometer built into the Nokia N95. I decided to convert a simple example: the ‘ball.py’ example that ships with Nokia’s distribution of Python for Series 60 (SourceForge).

The ball.py example uses the arrow keys to move a ball around the screen. Instead, I wanted to tilt the screen to do it.

The result came out reasonably well: I even used the webcam on the eeepc to put together a little video:

The code is available from my Symbian page, which has received so few changes that it doesn’t actually even mention my 6600 that I got years ago, and have since upgraded from.

In my searches, I wasn’t able to find a lot of source code for pure-Python scripting using the accelerometer, so hopefully if anyone is looking for demos of accelerometer usage, they can take this as an example in Python.

Love to hear any feedback if anyone else gives it a shot…

Comments

7 responses to “accelball: Python + N95 accelerometer demo”

  1. James Fee Avatar

    Well at least I was able to watch the YouTube video on my iPhone. Seriously though, that is impressive.

  2. Kent Johnson Avatar

    Very cool. You could make one of those labyrinth games where you tilt the maze to move a ball past holes and navigate a maze.

  3. Ilya Sitnikov Avatar

    Yeah – great stuff.

    I’m kinda jealous (in a good way) of people who come up with some of those things.

    🙂

  4. DieBagger Avatar
    DieBagger

    Very nicely done, congrats 😉

  5. Theo Nelson Avatar
    Theo Nelson

    How does one get this nifty app running ??

  6. Raj Godbole Avatar
    Raj Godbole

    Do all N95s have the accelerometer sensor? When I do a sensor.sensors()[‘AccSensor’] I get a KeyError, but when I do a sensor.sensors()[‘RotSensor’] I get the category and id. Shouldn’t just doing sensor.sensors() return all available sensors?

    Thanks in advance and thanks for the great example.

  7. James Avatar
    James

    Same question (different year) as Raj Godbole – I get a KeyError for AccSensor but can do the RotSensor, no prob. Any pointers? Thanks!