Overview
Amazon's playful boxes
Amazon recently started shipping boxes that include graphics which can be cut out and turned into masks. This project takes it a step further and repurposes the entire box to create an animatronic panda friend.
For this project, most any rectangular shipping box will work, but an A3 box seems to have just the right proportions.
If you don't have an Amazon box that has these graphics, do not fear! Drawing whatever you like with a sharpie pen does the trick just as well. You can create any animal you want!
We have the technology
This project pairs CRICKIT and Circuit Playground Express with two servo motors.
Other supplies you will need
The other supplies can be found around the home. Along with a box you will need:
- Scissors
- Double-sided tape
- String or fishing line (~20 inches long)
The box will be flipped on one end with the top flap folded down and the other three flaps bent outwards.
Page last edited March 08, 2024
Create your Panda
Cut out the legs
These legs can be as simple or as fancy as you want. Two hemispheres will do, or you can add extra features like claws!
Cut out the arms
These arms will attach to a servo motor and flap back and forth. Make them as simple or as complicated as you like.
Cut out the face
Cut out and tape your panda face to a scrap length of cardboard. This piece of cardboard will hold out and suspend the panda face in front of the box. Tape this face to the top of the box.
Add a door
Use a spare piece of scrap cardboard to tape a door to the front of your panda. This will create a space to store your CRICKIT.
Page last edited March 08, 2024
Add Electronics
Now it's time to add electronics to the panda!
Cut another rectangular hole in front flap of the box.
Insert second servo motor into this hole.
The fit should be fairly tight so it doesn't fall out accidentally.
Synchronized Servos
CRICKIT can control up to four servos at once! For this project we will only need two. We will use Mu to upload the CircuitPython code to Circuit Playground Express and control both servos simultaneously.
If you have not used Mu before, this is the guide on how to install it
For a quick primer on using CircuitPython and Servos, it is recommended to read through this learn guide as well.
Connect your servos to CRICKIT as shown in the diagram below. Be sure the yellow wire faces the edge of the CRICKIT board and the brown/black wire faces the Circuit Playground Express.
Page last edited March 08, 2024
Making Connections
Use fishing line or string to tie a loop around your panda's arms.
Tie the other end to the tip of the servo hub. This will pull the arms back and forth in a flapping motion.
Page last edited March 08, 2024
Uploading Code with Mu
But first...
To use Circuit Playground Express and CRICKIT together, you'll first need to install the special 'seesaw' version of the CPX firmware. This guide will take you through how to install CRICKIT support onto your circuit playground express.
Adafruit recommends editing your code in the Mu Editor which is super simple to use and has features to help us code and see results. See this guide on installing Mu.
Once you have completed this step you're ready to move on.
1) Connect Circuit Playground Express to your computer with a micro USB cable
2) Copy & paste the code below into the Mu Editor
3) Press the Save button in Mu - your code should be saved to the CIRCUITPY disk drive (which appears when the Circuit Playground Express is plugged into your computer) as code.py. If you name the program something else, like panda.py, the Circuit Playground Express won't automatically run it, that's why it's named code.py.
# SPDX-FileCopyrightText: 2018 Limor Fried/ladyada for Adafruit Industries
#
# SPDX-License-Identifier: MIT
# Code for the Trash Panda tutorial with Adafruit Crickit and Circuit Playground Express
import time
import board
from digitalio import DigitalInOut, Direction
from adafruit_crickit import crickit
# built in LED
led = DigitalInOut(board.D13)
led.direction = Direction.OUTPUT
# TowerPro servos like 500/2500 pulsewidths, make the wings flap a full 180
crickit.servo_1.set_pulse_width_range(min_pulse=500, max_pulse=2500)
crickit.servo_2.set_pulse_width_range(min_pulse=500, max_pulse=2500)
print("Its TRASH PANDA TIME!")
while True:
print("tick")
led.value = True
crickit.servo_1.angle = 0
time.sleep(0.5)
crickit.servo_2.angle = 180
time.sleep(1.0)
print("tock")
led.value = False
crickit.servo_1.angle = 180
time.sleep(0.5)
crickit.servo_2.angle = 0
time.sleep(1.0)
# Code for the Trash Panda tutorial with Adafruit Crickit and Circuit Playground Express import time import board from digitalio import DigitalInOut, Direction from adafruit_crickit import crickit
We'll use the little red LED on the CPX to let us know visually what it's up to, so set that up as an output
# built in LED led = DigitalInOut(board.D13) led.direction = Direction.OUTPUT
We get from the crickit library access to the Servo #1 and Servo #2 ports, where we have our servos plugged in. The TowerPro servos we're using work best with a 500us to 2500us pulse width, so we let the servo objects know that.
# TowerPro servos like 500/2500 pulsewidths crickit.servo_1.set_pulse_width_range(min_pulse=500, max_pulse=2500) crickit.servo_2.set_pulse_width_range(min_pulse=500, max_pulse=2500)
Finally, in our loop we go through a cycle of setting the crickit.servo_1 and crickit.servo_2 angles from 0 to 180 with delays. Try changing those time.sleep() delays to speed up or slow down the movement of your panda! But note, if you try to go too fast, the servo won't have time to move all the way.
We blink the LED so you can see what part of the loop its running, look on your CPX to see the red LED next to the USB connector!
while True:
print("tick")
led.value = True
crickit.servo_1.angle = 0
time.sleep(0.5)
crickit.servo_2.angle = 180
time.sleep(1.0)
print("tock")
led.value = False
crickit.servo_1.angle = 180
time.sleep(0.5)
crickit.servo_2.angle = 0
time.sleep(1.0)
Save & Run Code!
Check that both servos are rotating back and forth.
You should also be able to open the REPL within Mu, via pressing the button labeled REPL, and see "tick tock" printing out on your screen.
Exploring further
If you enjoy CircuitPython and want to continue learning you can find lots more CircuitPython projects on the Adafruit Learn System.
Page last edited March 08, 2024