This 3D printed heart beats rhythmically, powered by a servo motor and a Circuit Playground Express board connected to a potentiometer, which allows the user to increase or decrease the heart rate.

This spooky installation is a great introduction to coding with MakeCode and is a fun way to freak out your next guests!


A Black woman's manicured hand holds a round microcontroller with lit up LEDs.
Circuit Playground Express is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and...
In Stock
Continuous Rotation Servo with three pin cable
This servo rotates fully forward or backward instead of moving to a position. You can use any servo code, hardware, or library to control these servos. Good for making simple moving...
In Stock
Top view shot of JST 2-pin Extension Cable with On/Off Switch.
By popular request - we now have a way you can turn on-and-off Lithium Polymer batteries without unplugging them.This PH2 Female/Male JST 2-pin Extension...
In Stock
Group of Small Alligator Clip to Male Jumper Wires
When working with unusual non-header-friendly surfaces, these handy cables will be your best friends! No longer will you have long, cumbersome strands of alligator clips. These...
In Stock
hand slowly sliding potentiometer back and forth - 45mm Long.
Slip slidin' away Slip slidin' away You know the nearer your resistance The more you're slip slidin' awayIf you're...
In Stock


In addition to the electronics, for this project you will also need:

Read on to learn how to build your own!

Power Supply

Circuit Playground Express can use a variety of power sources, anywhere between 3V-5V is safe. This compact 2200mAh lithium ion cylindrical battery is excellent for powering projects like this. 

A set of 3 AAA batteries also provides ample power, if that option is more convenient. If you're using a AAAx3 battery pack, check that the switch on the battery pack is set to "ON".

Top view of Adafruit Micro Lipo - USB LiIon/LiPoly charger - v1 above a 2-pin JST cable.
Oh so adorable, this is the tiniest little lipo charger, so handy you can keep it any project box! Its also easy to use. Simply plug in the gold plated contacts into any USB port and a...
In Stock
Lithium Ion Cylindrical Battery - 3.7v 2200mAh with JST PH connector
Need a big battery for your project? This lithium-ion battery contains a 2200mAh and a protection circuit that provides over-voltage, under-voltage, and over-current protection. Yet,...
In Stock

- OR -

Front angled shot of 3 x AAA battery holder with on-off switch and 2-pin JST PH connector.
This battery holder connects 3 AAA batteries together in series for powering all kinds of projects. We spec'd these out because the box is slim, and 3 AAA's add up to about...
In Stock
Angled shot of 3 PKcell AAA batteries.
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 AAA's. This is a...
In Stock

Getting Familiar

This project runs a simple Microsoft MakeCode sketch to control the helmet, and is easy to play with if you want to make changes.

Microsoft MakeCode for Adafruit is a web-based code editor that provides a block editor, similar to Scratch or, and also a JavaScript editor for more advanced users.

If you've never used the Circuit Playground Express with MakeCode before, this guide is a good place to start.

The Code

The code is shown below. For browser viewing, you may need to enable content. For example, in Chrome, click "Show Embedded Content" as the material is fed not from Adafruit but from Microsoft's MakeCode site.

To download the code, click the download link at the bottom of the window. To edit the code in MakeCode, click the box with arrow icon in the upper right corner of the window.

How to Upload Code

To upload code to Circuit Playground Express, follow these instructions:

1) Connect your Circuit Playground Express to your computer using a known, good data+power micro USB cable and press the small reset button in the center of the board. All the LEDs will flash red briefly, then turn green. Your computer should now show a removable drive called CPLAYBOOT. 

2) Click the Download button in the code window below to download the .UF2 file to your computer.

3) Now drag and drop the .UF2 file onto the CPLAYBOOT drive in your computer's file explorer or finder.

Once the file is dragged onto CPLAYBOOT, the drive will automatically eject itself (your computer may give you a "failed to eject drive correctly" error, you can ignore this). The code is now on your Circuit Playground Express and ready to run!

Note: If you get a drive named CIRCUITPY, no worries! Press the reset button twice to get a flash drive named CPLAYBOOT. The project will not run if copied onto the CIRCUITPY drive as it is for CircuitPython.

What does this code do?

In the forever loop, we tell the pixels to turn red and change their brightness in accordance with the sound level.

The servo is set to rotate at a speed that is set by the position of a potentiometer with 0 being fastest and 90 being a standstill. 


Problem: My motor doesn't move!

Solution: Make sure that your Circuit Playground Express is connected to a power source (anywhere between 3V-5V is safe). If you're using a AAAx3 battery pack, check that the switch on the battery pack is set to "ON". If you are using the LiPo battery, be sure it is fully charged using the charger in the Featured Products.


Problem: My Circuit Playground Express doesn't show up as CPLAYBOOT


  1. Be sure you have a Circuit Playground Express.  The Circuit Playground Classic will not work with MakeCode.
  2. If you get a drive named CIRCUITPY instead, press the reset button twice in succession to get to CPLAYBOOT.
  3. Some USB cables are "charge-only" and won't pass data. Try using a different USB cable and try using a different USB port on your computer.  
  4. With the Circuit Playground Express plugged into your computer with a micro USB cable, click the small reset button in the center of the board. The lights should all turn green. If they don't, try double-clicking the reset button.

If things still aren't working, head over to the Intro to Circuit Playground Express guide for more suggestions.

More MakeCode!

If you enjoy MakeCode and want to continue exploring you can check out lots more MakeCode projects on the Adafruit Learn System.

The 3D files for this project can be downloaded by clicking the button below.

This design for this project is based on the hollow anatomical heart model created by Brian Locicero.

Print Settings

Each of these quadrants requires some support. This project prints well with the following settings:

  • 0.2mm Layer Height / 0.4mm nozzle
  • 80mm/s printing speed
  • 20% infill
  • Supports: Yes

Once the heart pieces are printed, it's time to mount and motorize them! 

For this step in the process you will need some scrap cardboard, scissors/hobby knife, and a hot glue gun. 

Servo Motor

Cut out a square of cardboard about 5 inches to a side.

Cut a rectangular hole in this piece of cardboard just large enough to push the servo motor into.

Offset Disc

Use hot glue to add an offset disc to the motor hub. 

Start small, you can always glue on larger discs to amplify the beating of the heart if the motion is too subtle.

Now is a good time to connect your servo motor to Circuit Playground Express and test out its functionality.

Once the base is ready, it's time to prepare the heart for mounting.

Heart Quadrants

Cut 4 strips of cardboard, each about 1 inch wide and 5 inches long.

These will be attached with hot glue to each of the four heart quadrants, acting like hinges to allow each quadrant to move back and forth independently.

Glue to Base

Adjust the bend in each strip of cardboard, if necessary, so that each piece of the heart lines up nicely with its neighbor.

It's helpful to use a pen to mark the four positions around the servo motor, keeping the placement of each roughly equidistant.

Outer Layer

To create the outer layer of the heart, cut the end off one leg of red pantyhose (available here).

The compressive force of the elastic fabric will hold the quadrants of the heart pressed inwards.

The stretch of the hose holds things nicely. Non-stretch fabric may not hold things together as well.


At this point, you may want to give your beating heart a place to live. A small box works well to contain the electronics and give a stable platform for the heart as it beats.

This one uses the Adafruit shipping box that came with the parts, but any base or box will do.

Install Motor

Cut a rectangular hole that the base of the servo motor can fit into.

Power Switch

Place the power switch in the back, cutting two small holes for the cables to pass through.


Cut a thin opening where you'd like to place the potentiometer.

Screw the potentiometer into the box.

That's it, adjust the potentiometer to vary the beating frequency.

This guide was first published on Aug 28, 2019. It was last updated on Aug 28, 2019.