Here’s a bit of fun…
It’s just four servos connected to yet another ServoBlaster buffer board. Some simple Python programming can be used to create a variety of expressions. The advantage of this as a starter activity is that it’s really quite easy to make and yet works so well.
There’s a good range of emotions that can be shown – happy, sad, angry, confused. With a random number generator in Python, it’s possible to get it showing all sorts of faces.
I’m intending to upload a video of this in action shortly, once I’ve got my head around the processes involved…
Python Program:
import time import os import random shortdelay=1 DELAY = 0.2 left_eye = 0 right_eye = 1 left_mouth =2 right_mouth =3 def pwm(pin, angle): print("servo[" + str(pin) + "][" + str(angle) + "]") cmd = "echo " + str(pin) + "=" + str(angle) + " > /dev/servoblaster" os.system(cmd) time.sleep(DELAY) def random_face(): for movements in range(0,10): le_move=random.randint(75,225) pwm(left_eye,le_move) re_move=random.randint(75,225) pwm(right_eye,re_move) lm_move=random.randint(75,225) pwm(left_mouth,lm_move) rm_move=random.randint(75,225) pwm(right_mouth,rm_move) time.sleep(2) while True: random_face()