HTML

testfinchfunctions.py

Nov 18th, 2016
184
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. # testfinchfunctions, an example program for the Finch
  2. # Tests all parts of the Finch: prints all sensor values, changes the led
  3. # moves the wheels and beeps the buzzer.
  4.  
  5. from time import sleep
  6. from finch import Finch
  7.  
  8. finch = Finch()
  9. print('Temperature %5.2f' % finch.temperature())
  10. print()
  11.  
  12. finch.wheels(1.0, -1.0)
  13. sleep(0.5)
  14. finch.wheels(0.0, 0.0)
  15.  
  16. for count in range(5):
  17.  
  18.     finch.led(0, 50*count, 0)
  19.     x, y, z, tap, shake = finch.acceleration()
  20.     print ('Acceleration %5.3f, %5.3f %5.3f %s %s' %
  21.               (x, y, z, tap, shake))
  22.     left_light, right_light = finch.light()
  23.     print ('Lights %5.3f, %5.3f' % (left_light, right_light))
  24.     left_obstacle, right_obstacle = finch.obstacle()
  25.     print('Obstacles %s, %s' % (left_obstacle, right_obstacle))
  26.     print()
  27.     finch.buzzer(0.8, 100*count)
  28.     sleep(1)
  29.    
  30. finch.led('#FF0000')
  31. finch.buzzer(5, 440)
  32. sleep(5)    
  33.  
  34. finch.halt()
  35. finch.close()
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment