# Trash Panda

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/054/383/medium800/circuit_playground_projects_IMG_2700.jpg?1527166018)

# 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](https://www.awesomers.com/a-catalog-of-amazon-box-sizes) 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.

### Circuit Playground Express

[Circuit Playground Express](https://www.adafruit.com/product/3333)
 **Circuit Playground Express** is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! Not only did we pack even more sensors in, we also made it even easier to...

In Stock
[Buy Now](https://www.adafruit.com/product/3333)
[Related Guides to the Product](https://learn.adafruit.com/products/3333/guides)
![A Black woman's manicured hand holds a round microcontroller with lit up LEDs.](https://cdn-shop.adafruit.com/640x480/3333-05.jpg)

### Adafruit CRICKIT for Circuit Playground Express

[Adafruit CRICKIT for Circuit Playground Express](https://www.adafruit.com/product/3093)
Sometimes we wonder if robotics engineers ever watch movies. If they did, they'd know that making robots into servants always ends up in a robot rebellion. Why even go down that path? Here at Adafruit, we believe in making robots our&nbsp; **friends!**

So if you find...

In Stock
[Buy Now](https://www.adafruit.com/product/3093)
[Related Guides to the Product](https://learn.adafruit.com/products/3093/guides)
![Top down view of a Adafruit CRICKIT for Circuit Playground Express with a circular board connected. ](https://cdn-shop.adafruit.com/640x480/3093-07.jpg)

### Standard servo - TowerPro SG-5010

[Standard servo - TowerPro SG-5010](https://www.adafruit.com/product/155)
This high-torque standard servo can rotate approximately 180 degrees (90 in each direction). You can use any servo code, hardware, or library to control these servos. Good for beginners who want to make stuff move without building a motor controller with feedback & gearbox. Comes with 3...

Out of Stock
[Buy Now](https://www.adafruit.com/product/155)
[Related Guides to the Product](https://learn.adafruit.com/products/155/guides)
![Standard hobby servo with three pin cable](https://cdn-shop.adafruit.com/640x480/155-01.jpg)

### Micro servo

[Micro servo](https://www.adafruit.com/product/169)
Tiny little servo can rotate approximately 180 degrees (90 in each direction) and works just like the standard kinds you're used to but _smaller_. You can use any servo code, hardware, or library to control these servos. Good for beginners who want to make stuff move without...

Out of Stock
[Buy Now](https://www.adafruit.com/product/169)
[Related Guides to the Product](https://learn.adafruit.com/products/169/guides)
![Micro servo with three pin cable](https://cdn-shop.adafruit.com/640x480/169-06.jpg)

### 5V 2A (2000mA) switching power supply - UL Listed

[5V 2A (2000mA) switching power supply - UL Listed](https://www.adafruit.com/product/276)
This is an FCC/CE certified and UL listed power supply. Need a lot of 5V power? This switching supply gives a clean regulated 5V output at up to 2000mA. 110 or 240 input, so it works in any country. The plugs are "US 2-prong" style so you may need a plug adapter, but you can pick one...

Out of Stock
[Buy Now](https://www.adafruit.com/product/276)
[Related Guides to the Product](https://learn.adafruit.com/products/276/guides)
![Angled shot of power supply.](https://cdn-shop.adafruit.com/640x480/276-06.jpg)

### USB cable - USB A to Micro-B

[USB cable - USB A to Micro-B](https://www.adafruit.com/product/592)
This here is your standard A to micro-B USB cable, for USB 1.1 or 2.0. Perfect for connecting a PC to your Metro, Feather, Raspberry Pi or other dev-board or microcontroller

Approximately 3 feet / 1 meter long

Out of Stock
[Buy Now](https://www.adafruit.com/product/592)
[Related Guides to the Product](https://learn.adafruit.com/products/592/guides)
![USB cable - USB A to Micro-B - 3 foot long](https://cdn-shop.adafruit.com/640x480/592-01.jpg)

# 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.

![](https://cdn-learn.adafruit.com/assets/assets/000/054/248/medium800/circuit_playground_projects_IMG_2707.jpg?1526956911)

# Trash Panda

## 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!

![](https://cdn-learn.adafruit.com/assets/assets/000/054/282/medium800/circuit_playground_projects_IMG_2709.jpg?1527088012)

## 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.

![](https://cdn-learn.adafruit.com/assets/assets/000/054/283/medium800/circuit_playground_projects_IMG_2711.jpg?1527088027)

# 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.

![](https://cdn-learn.adafruit.com/assets/assets/000/054/356/medium800/circuit_playground_projects_IMG_2787.jpg?1527113427)

## 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.

![](https://cdn-learn.adafruit.com/assets/assets/000/054/284/medium800/circuit_playground_projects_IMG_2686.jpg?1527088040)

# Trash Panda

## Add Electronics

Now it's time to add electronics to the panda!

Cut a rectangular hole in the back of the box.

&nbsp;

Insert servo housing into cardboard.

![circuit_playground_projects_IMG_2764.jpg](https://cdn-learn.adafruit.com/assets/assets/000/054/305/medium640/circuit_playground_projects_IMG_2764.jpg?1527101050)

![circuit_playground_projects_IMG_2766.jpg](https://cdn-learn.adafruit.com/assets/assets/000/054/306/medium640/circuit_playground_projects_IMG_2766.jpg?1527101066)

![circuit_playground_projects_IMG_2767.jpg](https://cdn-learn.adafruit.com/assets/assets/000/054/307/medium640/circuit_playground_projects_IMG_2767.jpg?1527101074)

Cut another rectangular hole in front flap of the box.

&nbsp;

Insert second servo motor into this hole.

&nbsp;

The fit should be fairly tight so it doesn't fall out accidentally.

&nbsp;

&nbsp;

![circuit_playground_projects_IMG_2691.jpg](https://cdn-learn.adafruit.com/assets/assets/000/054/308/medium640/circuit_playground_projects_IMG_2691.jpg?1527101147)

![circuit_playground_projects_IMG_2692.jpg](https://cdn-learn.adafruit.com/assets/assets/000/054/309/medium640/circuit_playground_projects_IMG_2692.jpg?1527101162)

# Synchronized Servos

CRICKIT can control up to **four&nbsp;** 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](../../../../welcome-to-circuitpython/installing-mu-editor)

For a quick primer on using CircuitPython and Servos, it is recommended to [read through this learn guide](https://learn.adafruit.com/adafruit-crickit-creative-robotic-interactive-construction-kit/circuitpython-servos)&nbsp;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.

![](https://cdn-learn.adafruit.com/assets/assets/000/054/451/medium800/circuit_playground_projects_panda2_bb.png?1527199565)

![](https://cdn-learn.adafruit.com/assets/assets/000/054/321/medium800/circuit_playground_projects_IMG_2702.jpg?1527102955)

# Trash Panda

## Making Connections

Use fishing line or string to tie a loop around your panda's arms.

&nbsp;

Tie the other end to the tip of the servo hub. This will pull the arms back and forth in a flapping motion.

![circuit_playground_projects_IMG_2697.jpg](https://cdn-learn.adafruit.com/assets/assets/000/054/258/medium640/circuit_playground_projects_IMG_2697.jpg?1527006080)

![circuit_playground_projects_IMG_2698.jpg](https://cdn-learn.adafruit.com/assets/assets/000/054/259/medium640/circuit_playground_projects_IMG_2698.jpg?1527006096)

![circuit_playground_projects_IMG_2768.jpg](https://cdn-learn.adafruit.com/assets/assets/000/054/379/medium640/circuit_playground_projects_IMG_2768.jpg?1527126040)

![circuit_playground_projects_IMG_2678.jpg](https://cdn-learn.adafruit.com/assets/assets/000/054/380/medium640/circuit_playground_projects_IMG_2678.jpg?1527126060)

![circuit_playground_projects_IMG_2683.jpg](https://cdn-learn.adafruit.com/assets/assets/000/054/378/medium640/circuit_playground_projects_IMG_2683.jpg?1527126015)

Use double sided tape to affix servo hub to piece of cardboard.

&nbsp;

Press hub onto servo motor.

![circuit_playground_projects_IMG_2688.jpg](https://cdn-learn.adafruit.com/assets/assets/000/054/316/medium640/circuit_playground_projects_IMG_2688.jpg?1527101606)

![circuit_playground_projects_IMG_2689.jpg](https://cdn-learn.adafruit.com/assets/assets/000/054/317/medium640/circuit_playground_projects_IMG_2689.jpg?1527101639)

![circuit_playground_projects_IMG_2693.jpg](https://cdn-learn.adafruit.com/assets/assets/000/054/318/medium640/circuit_playground_projects_IMG_2693.jpg?1527101659)

![circuit_playground_projects_IMG_2694.jpg](https://cdn-learn.adafruit.com/assets/assets/000/054/319/medium640/circuit_playground_projects_IMG_2694.jpg?1527101678)

Cut a small square hole in the base of the box.

&nbsp;

This will allow you to feed 5V power into the box.

&nbsp;

Connect 5V power to your CRICKIT board.

![circuit_playground_projects_IMG_2769.jpg](https://cdn-learn.adafruit.com/assets/assets/000/054/302/medium640/circuit_playground_projects_IMG_2769.jpg?1527100855)

![circuit_playground_projects_IMG_2770.jpg](https://cdn-learn.adafruit.com/assets/assets/000/054/303/medium640/circuit_playground_projects_IMG_2770.jpg?1527100878)

![circuit_playground_projects_IMG_2772.jpg](https://cdn-learn.adafruit.com/assets/assets/000/054/304/medium640/circuit_playground_projects_IMG_2772.jpg?1527100890)

# Trash Panda

## 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](../../../../adafruit-crickit-creative-robotic-interactive-construction-kit/circuitpython-code) 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](https://learn.adafruit.com/welcome-to-circuitpython/installing-mu-editor).

Once you have completed this step you're ready to move on.

# Testing 1...2...3...

Follow these three steps to get your motors turning

1) Connect Circuit Playground Express to your computer with a micro USB cable

&nbsp;

2)&nbsp;Copy & paste the code below into the Mu Editor

&nbsp;

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`.

![circuit_playground_projects_IMG_2778.jpg](https://cdn-learn.adafruit.com/assets/assets/000/054/349/medium640/circuit_playground_projects_IMG_2778.jpg?1527111820)

![circuit_playground_projects_IMG_2780.jpg](https://cdn-learn.adafruit.com/assets/assets/000/054/350/medium640/circuit_playground_projects_IMG_2780.jpg?1527111827)

![circuit_playground_projects_Screen_Shot_2018-05-23_at_5.37.33_PM.png](https://cdn-learn.adafruit.com/assets/assets/000/054/351/medium640/circuit_playground_projects_Screen_Shot_2018-05-23_at_5.37.33_PM.png?1527111849)

![circuit_playground_projects_Screen_Shot_2018-05-18_at_2.50.04_PM.png](https://cdn-learn.adafruit.com/assets/assets/000/054/352/medium640/circuit_playground_projects_Screen_Shot_2018-05-18_at_2.50.04_PM.png?1527111880)

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Trash_Panda/code.py

# How The Code Works

We start by `import`ing all our helper libraries

```auto
# 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

```auto
# 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.

```auto
# 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!

```auto
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.

![](https://cdn-learn.adafruit.com/assets/assets/000/054/322/medium800thumb/circuit_playground_projects_servo_1.jpg?1527103721)

![](https://cdn-learn.adafruit.com/assets/assets/000/054/323/medium800thumb/circuit_playground_projects_servo_2.jpg?1527103668)

# Long Live Trash Panda!
![](https://cdn-learn.adafruit.com/assets/assets/000/054/340/medium800thumb/circuit_playground_projects_IMG_2700.jpg?1527110690)

# Exploring further

If you enjoy CircuitPython and want to continue learning you can find&nbsp;[lots more CircuitPython projects on the Adafruit Learn System](https://learn.adafruit.com/category/micropython-slash-circuitpython).


## Guide Products

### Circuit Playground Express

[Circuit Playground Express](https://www.adafruit.com/product/3333)
 **Circuit Playground Express** is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! Not only did we pack even more sensors in, we also made it even easier to...

In Stock
[Buy Now](https://www.adafruit.com/product/3333)
[Related Guides to the Product](https://learn.adafruit.com/products/3333/guides)
### Adafruit CRICKIT for Circuit Playground Express

[Adafruit CRICKIT for Circuit Playground Express](https://www.adafruit.com/product/3093)
Sometimes we wonder if robotics engineers ever watch movies. If they did, they'd know that making robots into servants always ends up in a robot rebellion. Why even go down that path? Here at Adafruit, we believe in making robots our&nbsp; **friends!**

So if you find...

In Stock
[Buy Now](https://www.adafruit.com/product/3093)
[Related Guides to the Product](https://learn.adafruit.com/products/3093/guides)
### Standard servo - TowerPro SG-5010

[Standard servo - TowerPro SG-5010](https://www.adafruit.com/product/155)
This high-torque standard servo can rotate approximately 180 degrees (90 in each direction). You can use any servo code, hardware, or library to control these servos. Good for beginners who want to make stuff move without building a motor controller with feedback & gearbox. Comes with 3...

Out of Stock
[Buy Now](https://www.adafruit.com/product/155)
[Related Guides to the Product](https://learn.adafruit.com/products/155/guides)
### Micro servo

[Micro servo](https://www.adafruit.com/product/169)
Tiny little servo can rotate approximately 180 degrees (90 in each direction) and works just like the standard kinds you're used to but _smaller_. You can use any servo code, hardware, or library to control these servos. Good for beginners who want to make stuff move without...

Out of Stock
[Buy Now](https://www.adafruit.com/product/169)
[Related Guides to the Product](https://learn.adafruit.com/products/169/guides)
### 5V 2A (2000mA) switching power supply - UL Listed

[5V 2A (2000mA) switching power supply - UL Listed](https://www.adafruit.com/product/276)
This is an FCC/CE certified and UL listed power supply. Need a lot of 5V power? This switching supply gives a clean regulated 5V output at up to 2000mA. 110 or 240 input, so it works in any country. The plugs are "US 2-prong" style so you may need a plug adapter, but you can pick one...

Out of Stock
[Buy Now](https://www.adafruit.com/product/276)
[Related Guides to the Product](https://learn.adafruit.com/products/276/guides)
### USB cable - USB A to Micro-B

[USB cable - USB A to Micro-B](https://www.adafruit.com/product/592)
This here is your standard A to micro-B USB cable, for USB 1.1 or 2.0. Perfect for connecting a PC to your Metro, Feather, Raspberry Pi or other dev-board or microcontroller

Approximately 3 feet / 1 meter long

Out of Stock
[Buy Now](https://www.adafruit.com/product/592)
[Related Guides to the Product](https://learn.adafruit.com/products/592/guides)

## Related Guides

- [Adafruit Circuit Playground Express](https://learn.adafruit.com/adafruit-circuit-playground-express.md)
- [LED Matrix Hourglass](https://learn.adafruit.com/led-matrix-hourglass.md)
- [Bluetooth-Controlled Matrix LED Sign using Bluefruit Connect](https://learn.adafruit.com/bluetooth-controlled-matrix-led-sign-using-bluefruit-connect.md)
- [PyPortal Email Display with Zapier and Adafruit IO](https://learn.adafruit.com/pyportal-email-display.md)
- [Piper Make With the Raspberry Pi Pico](https://learn.adafruit.com/piper-make-with-the-raspberry-pi-pico.md)
- [UFO Flying Saucer with Circuit Playground Express](https://learn.adafruit.com/ufo-circuit-playground-express.md)
- [Cartoon Network and Make Code - Rose Quartz Shield Umbrella](https://learn.adafruit.com/cartoon-network-and-make-code-rose-quartz-shield-umbrella.md)
- [Boomy The Boombox](https://learn.adafruit.com/boomy-the-boombox.md)
- [Stroboscopic Zoetrope](https://learn.adafruit.com/strobe-zoetrope.md)
- [Christmas Soundboard with NeoTrellis M4](https://learn.adafruit.com/xmas-sound-board.md)
- [Unicorn Christmas Stocking with Rainbow Lights & Sound](https://learn.adafruit.com/unicorn-christmas-stocking-with-lights-sound.md)
- [Pinball Controller for iPad](https://learn.adafruit.com/pinball-controll-ipad.md)
- [Make It Log](https://learn.adafruit.com/make-it-data-log-spreadsheet-circuit-playground.md)
- [Magical Light-up Dreidel](https://learn.adafruit.com/magical-light-up-dreidel.md)
- [Chilled Drinkibot](https://learn.adafruit.com/chilled-drinkibot.md)
- [CircuitPython Powered AT Hand-Raiser](https://learn.adafruit.com/at-hand-raiser.md)
