PyS60 and N95 Accelerometer example

                              
Here’s a little script to get you going with interfacing the N95′s accelerometer in PyS60 with the AXYZ module. Nothing ground braking here, but possibly a good starting point if you’re a bit stumped.

#Title   : Accelerometer Test
#Author  : Mike Terzza http://terzza.com
#Summary : An example application to demo interfacing with the accelerometer of an N95 with PyS60
#Version : 0.1
#Date    : 26/01/08
#

import e32
import axyz

def main(x,y,z):
    if x < -30:
        print "#"
    elif x > 30:
        print " " * 60, "#"
    else:
        if y > 0:
            barY = (y / 8) + 1
        else:
            barY = 1
        barX = (x + 30)- (barY / 2)
        print " " * barX, "#" * barY

axyz.connect(main)
e32.ao_sleep(15)
axyz.disconnect()

Tags: , ,

Leave a Reply