Damien George | fd04bb3 | 2014-01-07 17:14:05 +0000 | [diff] [blame^] | 1 | # log the accelerometer values to a file, 1 per second |
2 | |||||
3 | f = open('motion.dat', 'w') # open the file for writing | ||||
4 | |||||
5 | for 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 | |||||
14 | f.close() # close the file |