blob: 81f44f19a8fe1616f6d696aa2fe38e7a178156e3 [file] [log] [blame]
Damien Georgefd04bb32014-01-07 17:14:05 +00001# log the accelerometer values to a file, 1 per second
2
3f = open('motion.dat', 'w') # open the file for writing
4
5for i in range(60): # loop 60 times
6 time = pyb.time() # get the current time
7 accel = pyb.accel() # get the accelerometer data
8
9 # write time and x,y,z values to the file
10 f.write('{} {} {} {}\n'.format(time, accel[0], accel[1], accel[2]))
11
12 pyb.delay(1000) # wait 1000 ms = 1 second
13
14f.close() # close the file