Tuesday, December 17, 2013

Change the Color of the Finch's Beak (+ Moving the Finch)

#The following line is required for the Finch to work. 
#Please replace the import line with the Finch's location.
import edu.cmu.ri.createlab.terk.robot.finch.Finch as Finch
import random

def beakChanger():
  #This initializes the Finch
  fred = Finch()
 
  #Moves forward, green beak
  fred.setLED(0, 255, 0)
  fred.setWheelVelocities(100,100,1000)
 
  #Moves backward, gold beak
  fred.setLED(255,255,0)
  fred.setWheelVelocities(-100,-100,1000)
 
  #Spin left 1 second, random beak color
  fred.setLED(int(random.random()*255), int(random.random()*255), int(random.random()*255))
  fred.setWheelVelocities(-100,100,1000)
 
  #Quit the Finch
  fred.quit()
 

No comments:

Post a Comment