HTML

kaitlynbowman.py

Nov 18th, 2016
198
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.96 KB | None | 0 0
  1. from finch import Finch
  2. from time import sleep
  3. finch = Finch()
  4.  
  5. left, right = finch.obstacle()
  6. acceleration = finch.acceleration()[2]
  7.  
  8. while 1 == 1:
  9.     #while no obstacles are detected
  10.     while acceleration > -0.7:
  11.         left,right = finch.obstacle()
  12.  
  13.         #set a green light
  14.         finch.led(0,255,0)
  15.    
  16.         #if any obstacles ARE detected...
  17.         if left:
  18.             finch.led(255,0,0);
  19.             finch.buzzer(4.5,17);
  20.             finch.wheels(-0.3,-1.0);
  21.             sleep(1.5);
  22.             finch.wheels(1,1);
  23.             sleep(3);
  24.             finch.wheels(0,0);
  25.        
  26.     # reverse and move away if there's something on the right
  27.         elif right:
  28.             finch.led(255,0,0);
  29.             finch.buzzer(4.5,17);
  30.             finch.wheels(-1.0, -0.3);
  31.             sleep(1.5);
  32.             finch.wheels(1,1);
  33.             sleep(3);
  34.             finch.wheels(0,0);
  35.  
  36.     acceleration = finch.acceleration()[2]
  37.  
  38. finch.close()
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment