-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtestfinchfunctions.py
More file actions
35 lines (28 loc) · 912 Bytes
/
testfinchfunctions.py
File metadata and controls
35 lines (28 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# testfinchfunctions, an example program for the Finch
# Tests all parts of the Finch: prints all sensor values, changes the led
# moves the wheels and beeps the buzzer.
from time import sleep
from finch import Finch
finch = Finch()
print('Temperature %5.2f' % finch.temperature())
print()
finch.wheels(1.0, -1.0)
sleep(0.5)
finch.wheels(0.0, 0.0)
for count in range(5):
finch.led(0, 50*count, 0)
x, y, z, tap, shake = finch.acceleration()
print ('Acceleration %5.3f, %5.3f %5.3f %s %s' %
(x, y, z, tap, shake))
left_light, right_light = finch.light()
print ('Lights %5.3f, %5.3f' % (left_light, right_light))
left_obstacle, right_obstacle = finch.obstacle()
print('Obstacles %s, %s' % (left_obstacle, right_obstacle))
print()
finch.buzzer(0.8, 100*count)
sleep(1)
finch.led('#FF0000')
finch.buzzer(5, 440)
sleep(5)
finch.halt()
finch.close()