Overview

This project expands upon the well-worn technique of using a hand tracing to make a turkey, but adapts it to create a moving, talking, interactive piece of Thanksgiving art.  

This robotic turkey responds to being tapped by wiggling its head and saying "gobble gobble". 

Parts

1 x Adafruit CRICKIT for Circuit Playground Express
Creative Robotics and Interactive Construction Kit is an add-on to our popular Circuit Playground Express that lets you #MakeRobotFriend using CircuitPython
1 x Circuit Playground Express
Circuit Playground Express is the perfect introduction to electronics and programming
1 x Sub-micro Servo - SG51R
This tiny servo can rotate approximately 180 degrees and works just like a standard servo but much smaller. Good for beginners who want to make stuff move. You can use any servo code, hardware or library to control these servos.
1 x Mini Metal Speaker
1" diameter speaker cone with an 8 Ω impedance and 0.5W or less of power draw.
1 x Alkaline AA batteries - 3 pack
These batteries are good quality at a good price, and work fantastic with any of the kits or projects that use AAs.
1 x 3xAA holder with DC jack
Battery holder 3xAA batteries with 2.1mm DC jack
1 x USB cable - A/MicroB - 3ft
Standard A to micro-B USB cable
1 x 5V 2A (2000mA) switching power supply
Power supply that gives a clean regulated 5V output at up to 2000mA, 110 or 240 volt AC input

Materials & Tools

To build this project you'll need:

Create Your Turkey

As turkey-texture, this guide uses an image of autumn leaves, but really any fall-related image makes a good backdrop for the turkey. You can alternatively trace an adult hand and color in using pencil or crayon.

Print your preferred image and glue it to a piece of scrap cardboard, or use the same autumn leaves, linked below.

Once your glue has taken hold, we're ready to start carving our bird.

Hand Tracing

 

Once you've glued your image to a piece of cardboard, flip it over and trace your hand on the back.

 

Cut out this tracing with scissors or a hobby knife.

Turkey Face

 

Cut a small triangle from the leftover scrap cardboard. This piece will become the turkey's beak.

 

Glue on eye and beak. A small piece of paper can help affix the beak in place.

Off with its Head

 

Remove turkey head at the point where the thumb joins with palm.

Motor Mount

 

Use hot glue to attach a small square of cardboard to the back of the hand.

 

A thin rectangle of cardboard can be used to expand the servo arm, making it easier to attach things to.

 

Stick servo motor to the motor mount using double sided tape or glue.

Re-attach the Head

 

Tape the turkey head onto servo arm using a small rectangle of double sided tape.

Hand Support

 

Glue support struts to base of hand.

 

These will help attach the hand to a platform.

Create the Base

 

Cut out a rectangle of cardboard to serve as a platform on which to mount the turkey.

 

Using your CRICKIT board as a gauge, mark two lines where the cardboard will fold.

 

Glue a strip of cardboard between the two folded sections, holding them at 90 degrees.

Now that the physical structure is together, it's time to incorporate the CRICKIT and connect everything.

The circuit diagram below shows the connections that need to be made.

Connect CRICKIT

 

Cut a hole in the middle of the base. This will allow the servo motor cable to connect to CRICKIT. 

 

Stick CRICKIT inside the base, feed the servo motor cable through a hole and connect it to the servo pins (lightest color wire facing in).

Add Audio

 

Connect speaker to the Speaker terminal block on the CRICKIT.

 

This speaker can be inconspicuously mounted inside using a small square of double sided tape.

CircuitPython

Onto the final step, the code itself!

For this project, we will be using CircuitPython.

Getting Familiar

CircuitPython is a programming language based on Python, one of the fastest growing programming languages in the world. It is specifically designed to simplify experimenting and learning to code on low-cost microcontroller boards.

CircuitPython is easiest to use within the Mu Editor. If you haven't previously used Mu, this guide will get you started.

If you haven't used Circuit Playground Express with CRICKIT before, make sure you've updated it with the latest special 'seesaw' version of the CPX firmware. This guide will show you how.

Copy that Code!

Copy code.py from the link below and put it in CIRCUITPY root directory. You can work with this code in any text editing application, or open and save with Mu if you prefer. 

import os
import time
import random
import board
from busio import I2C
import audioio
import adafruit_lis3dh
from adafruit_crickit import crickit

# Create accelerometer object for Circuit Playground Express
i2c1 = I2C(board.ACCELEROMETER_SCL, board.ACCELEROMETER_SDA)
lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c1, address=0x19)
# Changing RANGE_4_G to RANGE_2_G is more sensitive, RANGE_8_G less sensitive

lis3dh.range = adafruit_lis3dh.RANGE_4_G

# Audio playback object and helper to play a full file
a = audioio.AudioOut(board.A0)

# Find all Wave files on the storage
wavefiles = [file for file in os.listdir("/")
             if (file.endswith(".wav") and not file.startswith("._"))]
print("Audio files found: ", wavefiles)

# mouth servo
mouth_servo = crickit.servo_1
# TowerPro servos like 500/2500 pulsewidths
mouth_servo.set_pulse_width_range(min_pulse=500, max_pulse=2500)

# Servo angles
MOUTH_START = 90
MOUTH_END = 80

# Starting servo location
mouth_servo.angle = MOUTH_START

# Play a wave file and move the mouth while its playing!
def play_file(wavfile):
    print("Playing", wavfile)
    with open(wavfile, "rb") as f:
        wav = audioio.WaveFile(f)
        a.play(wav)
        while a.playing:  # turn servos, motors, etc. during playback
            mouth_servo.angle = MOUTH_END
            time.sleep(0.15)
            mouth_servo.angle = MOUTH_START
            time.sleep(0.15)

while True:
    if lis3dh.shake(shake_threshold=10):  # can also adjust sensitivity here
        print("Shake detected!")
        play_file(random.choice(wavefiles))
    # hang out for tiny bit
    time.sleep(0.05)

Talking Turkey

Now it's time to give your turkey something to say. This public domain turkey gobble sound is a good place to start (file courtesy of Soundbible.com).

Download the WAV file, the drag and drop that WAV file onto your CIRCUITPY drive.

Your CIRCUITPY drive should now contain the code.py file and WAV audio file.

Once you are at this stage you are ready to move on to the next step: testing!

Gobble Gobble!

Test it

Give your turkey a shake! It should respond by wobbling its head and playing the WAV file. 

If all is working well, give yourself a high five! You did it!

You can add different WAV files to your CIRCUITPY drive if you'd like your turkey to respond with different audio responses, or change your turkey's code to make it more or less sensitive to vibrations.

Troubleshooting

Problem: My Circuit Playground Express isn't recognized by Mu!

Solution: Make sure your board is set up with CircuitPython, which has the Circuit Playground Express show up as a flash drive named CIRCUITPY when you connect the CPX to your computer. If it is showing up as CPLAYBOOT on your computer, you can follow the steps in this guide to ensure CircuitPython is loaded and you see the CIRCUITPY drive.

 

Problem: My servo isn't moving!

Solution: Check that a 5V power supply is connected and the slide switch on CRICKIT is set to "ON". The lightest color servo wire faces the center of Crickit, the darkest faces outwards.

 

Problem: My servo still isn't moving! 

Solution: Make sure you've updated your Circuit Playground Express with the latest special 'seesaw' version of the CPX firmware. This guide will show you how.

This guide was first published on Nov 21, 2018. It was last updated on Nov 21, 2018.