# Lucky Cat with Circuit Playground Express

## Overview

https://youtu.be/y8h2Ihg0dX8

You have probably seen one of the adorable cats in the video above or in the picture below while out on the town: Lucky Cats. What is a Lucky Cat? Via [Wikipedia](https://en.wikipedia.org/wiki/Maneki-neko):

> The&nbsp;_ **maneki-neko** _&nbsp;(Japanese:&nbsp;招き猫, literally " **beckoning cat**")&nbsp;is a common&nbsp;Japanese&nbsp;figurine (lucky charm, talisman) which is often believed to bring&nbsp;good luck&nbsp;to the owner. In modern times, they are usually made of&nbsp;ceramic&nbsp;or plastic. The figurine depicts a&nbsp;cat&nbsp;(traditionally a&nbsp;[calico](https://en.wikipedia.org/wiki/Calico_cat "Calico cat")&nbsp;[Japanese Bobtail](https://en.wikipedia.org/wiki/Japanese_Bobtail "Japanese Bobtail")) beckoning with an upright paw, and is usually displayed in—often at the entrance of—shops, restaurants,&nbsp;pachinko&nbsp;parlors, and other businesses. Some of the sculptures are electric or battery-powered and have a slow-moving paw beckoning.
> 
> _Maneki-neko_&nbsp;comes in different colors, styles and degrees of ornateness. Common colors are white, black, gold and sometimes red. In addition to ceramic figurines,&nbsp;_maneki-neko_&nbsp;can be found as&nbsp;keychains,&nbsp;piggy banks,&nbsp;air fresheners, house-plant pots, and miscellaneous ornaments, as well as large statues. It is also sometimes incorrectly called the "Chinese lucky cat" because of its popularity among&nbsp;Chinese&nbsp;merchants.

![](https://cdn-learn.adafruit.com/assets/assets/000/070/129/medium800/makecode_cat-small.png?1548704979 Lucky Cat art, design by freepik - www.freepik.com, free to use credited to freepik)

This project will replicate a waving Lucky Cat with papercraft, an Adafruit Circuit Playground Express microcontroller, and a servo motor to wave the cat's paw.

**PROJECT UPDATE: An additional variation with a "Lucky Pig" for lunar New Year.**

The Circuit Playground Express may be coded in Microsoft MakeCode, CircuitPython, or the Arduino IDE. This guide will show you the code for MakeCode and CircuitPython.

## Parts

The project uses only a few parts and runs on standard AA batteries for extended use.

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

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

In 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)

### 3 x AA Battery Holder with On/Off Switch, JST, and Belt Clip

[3 x AA Battery Holder with On/Off Switch, JST, and Belt Clip](https://www.adafruit.com/product/3287)
This battery holder connects 3 AA batteries together in series for powering all kinds of projects. We spec'd these out because the box is compact, and 3 AA's add up to about 3.3-4.5V, a very similar range to Lithium Ion/polymer (Li-Ion) batteries, plus it has&nbsp;a nifty&nbsp;on-off...

In Stock
[Buy Now](https://www.adafruit.com/product/3287)
[Related Guides to the Product](https://learn.adafruit.com/products/3287/guides)
![Angled shot of 3 x AA battery holder with on/off switch, JST, and belt clip.](https://cdn-shop.adafruit.com/640x480/3287-00.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)

## Materials

Besides the parts above, you will want to have the following:

- Piece of cardboard, approximately 10" x 10 " (25 cm x 25 cm)
- Print of cat (template downloadable in this guide)
- A half a straw, popsicle stick, or small piece of wood to brace the cat arm
- Scissors or craft knife
- Tape and/or glue

### Alkaline AA batteries (LR6) - 3 pack

[Alkaline AA batteries (LR6) - 3 pack](https://www.adafruit.com/product/3521)
Battery power for your portable project! These batteries are good quality at a good price, and work fantastic with any of the kits or projects in the shop that use AAs. This is a pack of **3 AA batteries**.  
  
These batteries are Alkaline (MnO2) chemistry, with a voltage...

In Stock
[Buy Now](https://www.adafruit.com/product/3521)
[Related Guides to the Product](https://learn.adafruit.com/products/3521/guides)
![Angled shot of 3 AA batteries.](https://cdn-shop.adafruit.com/640x480/3521-00.jpg)

# Lucky Cat with Circuit Playground Express

## Construction

## Art

Decide on what type of animal or artwork you wish to animate. Two choices are below but you are free to choose nearly anything that can be animated with waving.

Be sure that when the chosen image is printed out, it is a good size, eight to ten inches (20-25 cm) tall.

### Lucky Cat Art

Click the button below to download the lucky cat art shown in the overview page. You'll need to ensure you credit the art to freepik. If you would like to draw your own image or find another picture, no problem. Do pick a cat that the arm, when cut out separately, will look natural when moving (waving / beckoning).

[Lucky Cat Art on freepik.com](https://www.freepik.com/free-vector/maneki-neko-lucky-cat-vector_719784.htm)
### Lucky Pig Art

Click the button below to download the lucky pig art shown in the overview page. You'll need to sign up for free to download. If you would like to draw your own image or find another picture, no problem. Do pick a pig that the arm, when cut out separately, will look natural when moving (waving).

[Lucky Pig Art](https://pngtree.com/freepng/lucky-pig_733370.html)
## Build
If you need to do any image editing to your picture, do it now. For the pig I flipped it vertical so have the moving hand on the viewer's right like the cat.

&nbsp;

Get a piece of cardboard at least as big as the drawing. I used a larger white Adafruit shipping box but any cardboard or similar material will do. Trace the outline of the animal and arm on the cardboard.

&nbsp;

Using scissors or a craft/x-acto knife, carefully cut the cardboard outline of the animal. If the arm is not separate at this point, carefully cut to separate the arm from the rest of the body.

&nbsp;

With the remaining cardboard, cut an approximately 8.5" (22 cm) by 1.25" (3 cm) strip of cardboard for a stand.

![makecode_01.jpg](https://cdn-learn.adafruit.com/assets/assets/000/070/185/medium640/makecode_01.jpg?1548791941)

![makecode_02.jpg](https://cdn-learn.adafruit.com/assets/assets/000/070/186/medium640/makecode_02.jpg?1548792002)

![makecode_03.jpg](https://cdn-learn.adafruit.com/assets/assets/000/070/187/medium640/makecode_03.jpg?1548792016)

![makecode_04.jpg](https://cdn-learn.adafruit.com/assets/assets/000/070/188/medium640/makecode_04.jpg?1548792049)

![makecode_Pig.png](https://cdn-learn.adafruit.com/assets/assets/000/071/078/medium640/makecode_Pig.png?1549999815)

Using glue stick or a thin coat of craft/white glue, place a thin layer of glue on the cardboard pieces.

Attach the paper parts to the cardboard to make a rigid animal and arm.&nbsp;

![makecode_05.jpg](https://cdn-learn.adafruit.com/assets/assets/000/070/189/medium640/makecode_05.jpg?1548792173)

## Attaching the Stand

&nbsp;

Take the strip of cardboard cut earlier and tape one end to the bottom of the cat. Using the battery pack as a guide, bend the cardboard so the width of the stand touching a flat surface os the same as the battery pack width.

Bend the cardboard up, making a triangular shape towards the head. Tape the end of the stand strip to the head such that the car overall tilts slightly back but still fairly straight.

![makecode_07.jpg](https://cdn-learn.adafruit.com/assets/assets/000/070/191/medium640/makecode_07.jpg?1548793856)

![makecode_08.jpg](https://cdn-learn.adafruit.com/assets/assets/000/070/192/medium640/makecode_08.jpg?1548793908)

![makecode_09.jpg](https://cdn-learn.adafruit.com/assets/assets/000/070/193/medium640/makecode_09.jpg?1548793946)

## Mounting the Servo to the Arm

&nbsp;

Using a straw, popsicle stick or similar, attach to the servo single arm horn (attachment) with a provided screw. Attach that to the cat awm securely via shallow screws or glue.

&nbsp;

The servo should be able to move the arm so that the servo body is on the cat, the place where the horn attaches is at the joint and the servo horn arm with straw is on the arm. This makes the servo like a shoulder joint.

&nbsp;

Test fit the arm with the cat body and adjust if necessary.

![makecode_arm.jpg](https://cdn-learn.adafruit.com/assets/assets/000/070/779/medium640/makecode_arm.jpg?1549416586)

## Attach the Servo and Larger Parts

&nbsp;

Align the arm with the servo attached to the cat body such that there is about 1/8" (2 mm) gap between the arm and body such that when the arm waves, it will not rub against the body. Using glue, glue the servo to the cat body, being sure the alignment is good. Let dry.

&nbsp;

&nbsp;

![makecode_pig_back_a1.jpg](https://cdn-learn.adafruit.com/assets/assets/000/071/081/medium640/makecode_pig_back_a1.jpg?1550000478)

![makecode_mount3.jpg](https://cdn-learn.adafruit.com/assets/assets/000/070/785/medium640/makecode_mount3.jpg?1549417168)

That's it. Next we'll choose which method to program the project. You can chose the super easy to use Microsoft MakeCode or the versatile CircuitPython.

# Lucky Cat with Circuit Playground Express

## Code with MakeCode

![](https://cdn-learn.adafruit.com/assets/assets/000/070/173/medium800/makecode.jpg?1548782188)

The code for this project is shown above and may be downloaded from the link below.

[Download the code in MakeCode](https://makecode.com/_Ro2fqhHTA6ig)
If you are new to Microsoft MakeCode on the Circuit Playground Express, we have a guide on getting you familiar with this great combination of hardware and software:

- [MakeCode for Circuit Playground Express](https://learn.adafruit.com/makecode)

## What is the Code Doing?

The code loops `forever`, first moving the `servo` motor from `0` degrees to `50` degrees (with a `.9` millisecond `pause` between angle changes). Then the code waits `150` milliseconds and reverses the angle of the servo from `50` degrees back to `0` degrees. The movement is timed to be fairly fluid without being too fast or too slow.

If you find the movement too fast or slow, adjust the times of the `pause` statements directly below the `servo write` block. A small addition or subtraction will do, you do not want the wave to be super fast or so slow.

The switch on the battery pack is used to turn the project on and off.

# Lucky Cat with Circuit Playground Express

## Code with CircuitPython

If you like, you can code this project using&nbsp;[CircuitPython](https://learn.adafruit.com/welcome-to-circuitpython/what-is-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. Here are some guides which cover the basics:

- [Welcome to CircuitPython!](https://learn.adafruit.com/welcome-to-circuitpython)
- [Adafruit Circuit Playground Express](https://learn.adafruit.com/adafruit-circuit-playground-express)

Be sure you have the latest CircuitPython loaded onto your board per the second guide.

CircuitPython is easiest to use within the Mu Editor. If you haven't previously used Mu,&nbsp;[this guide will get you started](https://learn.adafruit.com/welcome-to-circuitpython/installing-mu-editor).

## Download Library Files

Plug your Circuit Playground Express board into your computer via a USB cable. Please be sure the cable is a good power+data cable so the computer can talk to the Circuit Playground Express board.

A new disk should appear in your computer's file explorer/finder called **CIRCUITPY**. This is the place we'll copy the code and code library. If you can only get a drive named&nbsp; **CPLAYBOOT** , load CircuitPython per the guide above.

Create a new directory on the&nbsp; **CIRCUITPY** drive named **lib**.

Download the latest CircuitPython motor driver to your computer using the green button below. **Match the library you get to the version of CircuitPython you are using**. Save to your computer's hard drive where you can find it.

[Go to GitHub to get the latest CircuitPython library bundle](https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases/)
With your file explorer/finder, browse to the bundle and open it up. Copy the following folder from the library bundle to your&nbsp; **CIRCUITPY** &nbsp; **lib** &nbsp;directory you made earlier:

- **adafruit\_motor**

All of the other necessary code is baked into CircuitPython!

![](https://cdn-learn.adafruit.com/assets/assets/000/070/249/medium800/makecode_library.png?1548802931)

## Download Code

Below is the code for this project. Select download **code.py** &nbsp;below and save it to your computer's hard drive where you can find it.

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

Load the **code.py** &nbsp;file into Mu. Double click the tab **code.py** (save as) and select your Circuit Playground Express **CIRCUITPY** flash drive. When the file copies over, it will start immediately, as you have the USB powered so be careful of a moving paw. If it did not start, check you saved **code.py** onto the **CIRCUITPY** flash drive.

## Adjusting the timing of the servo
You will notice the timing of the `time.sleep` functions is different from the MakeCode values. MakeCode and CircuitPython code run at different speeds when converted to machine code.

You can change the values for the `time.sleep` but make small changes, lower = faster, higher = slower.

# Lucky Cat with Circuit Playground Express

## Final Wiring

![](https://cdn-learn.adafruit.com/assets/assets/000/070/134/medium800/makecode_Lucky_Cat_Wiring.png?1548708959)

## Connections

The servo wires end in a black block with three wires. We'll use jumper wires that have a pin that goes into the jumper and has an alligator clip on the end to make the connection to the round Circuit Playground Express. Using three of these jumpers, make the following connections:

- Sevo **red** to Circuit Playground Express pad **Vout**
- Servo **black** to Circuit Playground Express pad **GND**
- Servo **yellow** to Circuit Playground Express pad **A1**.

![](https://cdn-learn.adafruit.com/assets/assets/000/070/219/medium800/makecode_20190129_163455.jpg?1548798761 Connections to the Circuit Playground Express)

Coil any extra wire and use tape, a twist tie, tape, or a semi-rigid piece of wire to bundle the excess up out of the way.

Install fresh AA batteries into the battery holder. Turn the switch on the case to OFF for now. Plug the battery holder white connector into the black plastic connector on the Circuit Playground Express.

Check all connections with the diagram to be sure everything is connected. Ensure the Circuit Playground Express and Battery holder are adhered to the back of the cat via double-sided tape or similar.

# Lucky Cat with Circuit Playground Express

## Use

![](https://cdn-learn.adafruit.com/assets/assets/000/070/213/medium800thumb/makecode_ezgif-4-cbfa86351947.jpg?1548798521)

![](https://cdn-learn.adafruit.com/assets/assets/000/071/082/medium800thumb/makecode_Lucky_Pig.jpg?1550004488)

Be sure you have a weighted base, either the batteries or something else with some weight. You might tilt the animal back slightly for viewing and stability.&nbsp;

Turn the switch on the battery pack from OFF to ON. And enjoy your luck!

## Going Further

You can use the Lucky Cat as a template for many projects. Add LED / LCD / OLED eyes, sound, whatever suits your fancy.

Check out&nbsp;Maneki Neko Defcon (Twitter&nbsp;[@ManekiNekoDC](https://twitter.com/ManekiNekoDC))&nbsp; for the design below with multi-segment eyes in the style of #BadgeLife, an A+ Lucky Cat.

![](https://cdn-learn.adafruit.com/assets/assets/000/070/767/medium800/makecode_jl1dua-2.png?1549414010)

![](https://cdn-learn.adafruit.com/assets/assets/000/070/255/medium800/makecode_ff66RinC.jpg?1548810705 Photo courtesy of @ManekiNekoDC)

This work is by creators Sean McCabe and Daniel Samarin. The art is by&nbsp;Jeff Chang. There is an article on [Engadget](https://www.engadget.com/2018/08/15/this-cute-def-con-badge-beckons-you-to-hack-it/) and the project, info, and code are[&nbsp;on GitHub](https://github.com/seanleftbelow/defcon26-meow).


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

In Stock
[Buy Now](https://www.adafruit.com/product/169)
[Related Guides to the Product](https://learn.adafruit.com/products/169/guides)
### 3 x AA Battery Holder with On/Off Switch, JST, and Belt Clip

[3 x AA Battery Holder with On/Off Switch, JST, and Belt Clip](https://www.adafruit.com/product/3287)
This battery holder connects 3 AA batteries together in series for powering all kinds of projects. We spec'd these out because the box is compact, and 3 AA's add up to about 3.3-4.5V, a very similar range to Lithium Ion/polymer (Li-Ion) batteries, plus it has&nbsp;a nifty&nbsp;on-off...

In Stock
[Buy Now](https://www.adafruit.com/product/3287)
[Related Guides to the Product](https://learn.adafruit.com/products/3287/guides)
### Small Alligator Clip to Male Jumper Wire Bundle - 12 Pieces

[Small Alligator Clip to Male Jumper Wire Bundle - 12 Pieces](https://www.adafruit.com/product/3255)
For bread-boarding with unusual non-header-friendly surfaces, these cables will be your best friends! No longer will you have long strands of alligator clips that are grabbing little wires. These compact jumper cables have a premium male header on one end, and a grippy mini alligator clip on...

Out of Stock
[Buy Now](https://www.adafruit.com/product/3255)
[Related Guides to the Product](https://learn.adafruit.com/products/3255/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)
### Alkaline AA batteries (LR6) - 3 pack

[Alkaline AA batteries (LR6) - 3 pack](https://www.adafruit.com/product/3521)
Battery power for your portable project! These batteries are good quality at a good price, and work fantastic with any of the kits or projects in the shop that use AAs. This is a pack of **3 AA batteries**.  
  
These batteries are Alkaline (MnO2) chemistry, with a voltage...

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

## Related Guides

- [Adafruit Circuit Playground Express](https://learn.adafruit.com/adafruit-circuit-playground-express.md)
- [NeoPixie Dust Bag with Circuit Playground Express](https://learn.adafruit.com/neopixie-dust-bag-cpx.md)
- [Crickit Carnival Bumper Bot](https://learn.adafruit.com/crickit-carnival-bumper-car-bot.md)
- [Installing Microsoft MakeCode for Adafruit](https://learn.adafruit.com/installing-makecode-for-adafruit.md)
- [CircuitPython Basics: Analog Inputs & Outputs](https://learn.adafruit.com/circuitpython-basics-analog-inputs-and-outputs.md)
- [Circuit Playground Express Spooky Laughing Box](https://learn.adafruit.com/spooky-circuit-playground-express-mystery-box.md)
- [Make It Sense](https://learn.adafruit.com/make-it-sense.md)
- [The Tilt Trumpet](https://learn.adafruit.com/the-tilt-trumpet.md)
- [Case for Circuit Playground](https://learn.adafruit.com/case-for-circuit-playground.md)
- [Dancing Inflatables: Make your Holiday Display Move](https://learn.adafruit.com/dancing-inflatables-make-your-holiday-display-move.md)
- [How to Program SAMD Bootloaders](https://learn.adafruit.com/how-to-program-samd-bootloaders.md)
- [Program CircuitPython USB Devices with iPhone & iPad](https://learn.adafruit.com/use-circuitpython-devices-with-iphone-ipad.md)
- [Sound Activated Shark Mask](https://learn.adafruit.com/sound-activated-shark-mask.md)
- [Mason Jar Snow Globe](https://learn.adafruit.com/snow-globe-makecode.md)
- [Using EduBlocks with Circuit Playground Express](https://learn.adafruit.com/using-edublocks-with-circuit-playground-express.md)
- [CRICKIT Exhibit Demo Board](https://learn.adafruit.com/crickit-exhibit-demo-board.md)
