# Capacitive Touch Pulsing Heart

## Overview

Hold this heart in your hand and it automatically detects your touch and begins to glow, pulsing like a beating heart.

A Circuit Playground Express tucked away inside a 3D printed anatomical heart model uses its capacitive touch pad to detect when it's being held and pulse its onboard neopixels in response.

![](https://cdn-learn.adafruit.com/assets/assets/000/080/865/medium800thumb/biometric_Heart_hero_red.2019-09-12_17_21_36.jpg?1568404742)

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

### Lithium Ion Polymer Battery Ideal For Feathers - 3.7V 400mAh

[Lithium Ion Polymer Battery Ideal For Feathers - 3.7V 400mAh](https://www.adafruit.com/product/3898)
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This battery has a capacity of **400mAh** for a total of about 1.9 Wh. If you need a larger (or smaller!)...

In Stock
[Buy Now](https://www.adafruit.com/product/3898)
[Related Guides to the Product](https://learn.adafruit.com/products/3898/guides)
![Slim Lithium Ion Polymer Battery 3.7v 400mAh with JST 2-PH connector and short cable](https://cdn-shop.adafruit.com/640x480/3898-05.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

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

### Conductive Nylon Fabric Tape - 5mm Wide x 10 meters long

[Conductive Nylon Fabric Tape - 5mm Wide x 10 meters long](https://www.adafruit.com/product/3961)
With our fun assortment of&nbsp;[conductive materials](https://www.adafruit.com/category/190),&nbsp;[cosplay](https://www.adafruit.com/index.php?main_page=category&cPath=290)&nbsp;and&nbsp;[wearables](https://www.adafruit.com/category/65)&nbsp;have never...

In Stock
[Buy Now](https://www.adafruit.com/product/3961)
[Related Guides to the Product](https://learn.adafruit.com/products/3961/guides)
![Conductive Nylon Fabric Tape - 5mm Wide](https://cdn-shop.adafruit.com/640x480/3961-00.jpg)

### White Nylon Machine Screw and Stand-off Set – M2.5 Thread

[White Nylon Machine Screw and Stand-off Set – M2.5 Thread](https://www.adafruit.com/product/3658)
Totaling 420 pieces, this **White Nylon&nbsp;M2.5 Screw Set** &nbsp;is a must-have smörgåsbord for your workstation.&nbsp;You'll have more than enough screws, nuts, and hex standoffs to construct&nbsp;your maker projects&nbsp;for days on end! M2.5 screws fit nearly...

In Stock
[Buy Now](https://www.adafruit.com/product/3658)
[Related Guides to the Product](https://learn.adafruit.com/products/3658/guides)
![White Nylon Screw and Stand-off Set with M2.5 Threads, kit box](https://cdn-shop.adafruit.com/640x480/3658-00.jpg)

### Breadboard-friendly SPDT Slide Switch

[Breadboard-friendly SPDT Slide Switch](https://www.adafruit.com/product/805)
These nice switches are perfect for use with breadboard and perfboard projects. They have 0.1" spacing and snap in nicely into a solderless breadboard. They're easy to switch no matter what size fingers you have, but not so easy that they'll get flipped by accident. Work great as...

Out of Stock
[Buy Now](https://www.adafruit.com/product/805)
[Related Guides to the Product](https://learn.adafruit.com/products/805/guides)
![Small, black, SPDT slide switch.](https://cdn-shop.adafruit.com/640x480/805-03.jpg)

### Silicone Cover Stranded-Core Wire - 2m 26AWG Red

[Silicone Cover Stranded-Core Wire - 2m 26AWG Red](https://www.adafruit.com/product/1877)
Silicone-sheathing wire is super-flexible and soft, and its also strong! Able to handle up to 200°C and up to 600V, it will do when PVC covered wire wimps out. We like this wire for being extremely supple and flexible, so it is great for wearables or projects where the wire-harness has to...

In Stock
[Buy Now](https://www.adafruit.com/product/1877)
[Related Guides to the Product](https://learn.adafruit.com/products/1877/guides)
![Top shot of Red Silicone Cover Stranded ](https://cdn-shop.adafruit.com/640x480/1877-01.jpg)

## Materials

In addition to the materials listed above, for this project you will also need:

- Access to a 3D printer
- White or Red filament
- A piece of sandpaper
- Soldering iron (optional)

Read on to learn how to build your own!

![](https://cdn-learn.adafruit.com/assets/assets/000/080/867/medium800thumb/biometric_Untitled11.2019-09-13_16_08_10.jpg?1568405321)

# Capacitive Touch Pulsing Heart

## MakeCode

## Getting familiar with MakeCode

This project runs a simple MakeCode sketch and is easy to play with if you want to make changes.

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

If you've never used the Circuit Playground Express with MakeCode before,&nbsp;[this guide is a good place to start](https://makecode.adafruit.com/courses/maker/general/coding).

![](https://cdn-learn.adafruit.com/assets/assets/000/080/471/medium800/biometric_makecode.jpg?1567628632)

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

https://makecode.adafruit.com/87909-63069-07680-43032

## 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&nbsp; **red&nbsp;** briefly **, then turn green.&nbsp;** Your computer should now show a removable drive called&nbsp; **CPLAYBOOT.&nbsp;**

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

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

Once the file is dragged onto&nbsp; **CPLAYBOOT,** &nbsp;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&nbsp; **CIRCUITPY** , no worries! Press the reset button&nbsp; **twice** &nbsp;to get a flash drive named&nbsp; **CPLAYBOOT**. The project will not run if copied onto the&nbsp; **CIRCUITPY** &nbsp;drive as it is for CircuitPython.

![](https://cdn-learn.adafruit.com/assets/assets/000/080/866/medium800/biometric_Screen_Shot_2019-09-13_at_4.02.34_PM.png?1568405015)

## Making Changes

In the&nbsp;`on start`&nbsp;loop, we `set all pixels` to red and start with the brightness `0`, and set the sensitivity threshold to `200`.

The pixels are set to illuminate whenever the value of `analog read pin A2` goes over`200`,&nbsp;which can be done by touching it, resulting in an increase in the capacitance.&nbsp;

If you find your heart isn't sensitive to touch, or is too sensitive, you can change this value from 200 down to `150`&nbsp;or up to `800`(max 1023).

## Troubleshooting

**Problem:&nbsp;** My Circuit Playground Express doesn't show up as&nbsp; **CPLAYBOOT**

**Solutions:**

1. Be sure you have a Circuit Playground Express.&nbsp; The Circuit Playground Classic will not work with MakeCode.
2. If you get a drive named&nbsp; **CIRCUITPY** &nbsp;instead, press the reset button twice in succession to get to&nbsp; **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.&nbsp;&nbsp;
4. With the Circuit Playground Express plugged into your computer with a micro USB cable,&nbsp; **click the small reset button** &nbsp;in the center of the board. The lights should all turn green. If they don't, try&nbsp; **double-clicking** &nbsp;the reset button.

If things still aren't working, head over to the Intro to&nbsp;[Circuit Playground Express](https://learn.adafruit.com/adafruit-circuit-playground-express)&nbsp;guide for more suggestions.

# Capacitive Touch Pulsing Heart

## 3D Printing

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

This heart prints in two pieces that snap fit together. The back piece has two standoffs sticking out of it that the Circuit Playground Express can be screwed into. **Note** : the board must be tilted to get it to fit into the heart, so raising it up on some [nylon screw standoffs](https://www.adafruit.com/product/3658) is very helpful.

This design for this project is based on the hollow&nbsp;[anatomical heart model](https://www.thingiverse.com/thing:932606)&nbsp;created by&nbsp;[Brian Locicero](https://locicero.art/).

[Capacitive Heart 3D Files](https://www.thingiverse.com/thing:3855050/files)
![](https://cdn-learn.adafruit.com/assets/assets/000/080/545/medium800thumb/biometric_IMG_7150.2019-09-05_18_10_40.jpg?1567722043)

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

![](https://cdn-learn.adafruit.com/assets/assets/000/080/473/medium800/biometric_IMG_6997.jpg?1567629246)

![](https://cdn-learn.adafruit.com/assets/assets/000/080/755/medium800/biometric_IMG_7151.jpg?1568142078)

Because of the limitations of 3d printing, your piece may not fit together perfectly right off the printer.

If the fit is too tight, use a small piece of sandpaper to smooth the edges of the parts, allowing them to fit together snugly.

![](https://cdn-learn.adafruit.com/assets/assets/000/080/862/medium800/biometric_IMG_7418.jpg?1568399963)

# Capacitive Touch Pulsing Heart

## Assemble

![](https://cdn-learn.adafruit.com/assets/assets/000/080/754/medium800/biometric_IMG_6990.jpg?1568142055)

Tilt and rotate the back so that the Circuit Playground Express can fit into the opening.

Press the back piece so that it snaps into place.

![biometric_IMG_1590.jpg](https://cdn-learn.adafruit.com/assets/assets/000/080/853/medium640/biometric_IMG_1590.jpg?1568395625)

![biometric_IMG_1591.jpg](https://cdn-learn.adafruit.com/assets/assets/000/080/854/medium640/biometric_IMG_1591.jpg?1568395689)

![](https://cdn-learn.adafruit.com/assets/assets/000/080/855/medium800thumb/biometric_Untitled6.2019-09-06_14_09_23.jpg?1568396382)

## Optional: Power Switch

If you prefer a way to turn the circuit on and off without popping off the back of the heart, you can easily solder together a small switch for this purpose.

## Power Circuit

Create a small power switch for the battery.

Solder two wires to the [slide switch](https://www.adafruit.com/product/805). Insert these wires into the heart through the aorta.

Cut the ends off a [JST extension cable](https://www.adafruit.com/product/1131). Strip the tips and solder the black (GND) wires together.

Solder the switch so that it connects the red wires together. You now have a small and effective power switch!

![biometric_IMG_7153.jpg](https://cdn-learn.adafruit.com/assets/assets/000/080/748/medium640/biometric_IMG_7153.jpg?1568140967)

![biometric_IMG_7155.jpg](https://cdn-learn.adafruit.com/assets/assets/000/080/749/medium640/biometric_IMG_7155.jpg?1568141054)

![biometric_IMG_7156.jpg](https://cdn-learn.adafruit.com/assets/assets/000/080/750/medium640/biometric_IMG_7156.jpg?1568141669)

![biometric_IMG_7157.jpg](https://cdn-learn.adafruit.com/assets/assets/000/080/751/medium640/biometric_IMG_7157.jpg?1568141245)

![biometric_IMG_7158.jpg](https://cdn-learn.adafruit.com/assets/assets/000/080/752/medium640/biometric_IMG_7158.jpg?1568142718)

![biometric_IMG_7163.jpg](https://cdn-learn.adafruit.com/assets/assets/000/080/753/medium640/biometric_IMG_7163.jpg?1568141892)

With an external switch you can now turn on/off power without having to unplug the battery.

![](https://cdn-learn.adafruit.com/assets/assets/000/080/747/medium800thumb/biometric_Untitled5_turn_on.2019-09-10_13_09_38.jpg?1568140841)

# Capacitive Touch Pulsing Heart

## Explore Further

## Translucent Red

If you want an arguably more arresting object, printing this heart with translucent red filament creates a heart that glows brighter (due to the reduced opacity of the plastic), and has a blood-red look.&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/080/860/medium800/biometric_IMG_7416.jpg?1568398878)

![](https://cdn-learn.adafruit.com/assets/assets/000/080/856/medium800/biometric_IMG_1610.jpg?1568396417)

![](https://cdn-learn.adafruit.com/assets/assets/000/080/857/medium800thumb/biometric_Untitled13.2019-09-12_17_13_14.jpg?1568396466)

## Advanced Adaptations

If you really want to take this project to the next level (and increase your heart rate in the process), you could adapt the heart to use a [Pulse Sensor](https://www.adafruit.com/product/1093) that would read your heart rate and use that data to have the 3D printed heart beat in time with your own.&nbsp;

Some examples that have used this same idea can be found in Collin Cunningham's ["Pulse Room" project](https://learn.adafruit.com/pulse-room/) (below), or&nbsp;[this NeoPixel pulse display](https://learn.adafruit.com/pulse-sensor-displayed-with-neopixels)&nbsp;by Mike Barela, for any ambitious makers out there.

![](https://cdn-learn.adafruit.com/assets/assets/000/080/861/medium800thumb/biometric_Pulse_room_demo.2019-09-13_14_28_21.jpg?1568399332)

## More MakeCode!

If you enjoy MakeCode and want to continue exploring you can check out&nbsp;[lots more MakeCode projects on the Adafruit Learn System](https://learn.adafruit.com/category/makecode).


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

In Stock
[Buy Now](https://www.adafruit.com/product/592)
[Related Guides to the Product](https://learn.adafruit.com/products/592/guides)
### Lithium Ion Polymer Battery Ideal For Feathers - 3.7V 400mAh

[Lithium Ion Polymer Battery Ideal For Feathers - 3.7V 400mAh](https://www.adafruit.com/product/3898)
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This battery has a capacity of **400mAh** for a total of about 1.9 Wh. If you need a larger (or smaller!)...

In Stock
[Buy Now](https://www.adafruit.com/product/3898)
[Related Guides to the Product](https://learn.adafruit.com/products/3898/guides)
### Breadboard-friendly SPDT Slide Switch

[Breadboard-friendly SPDT Slide Switch](https://www.adafruit.com/product/805)
These nice switches are perfect for use with breadboard and perfboard projects. They have 0.1" spacing and snap in nicely into a solderless breadboard. They're easy to switch no matter what size fingers you have, but not so easy that they'll get flipped by accident. Work great as...

Out of Stock
[Buy Now](https://www.adafruit.com/product/805)
[Related Guides to the Product](https://learn.adafruit.com/products/805/guides)
### White Nylon Machine Screw and Stand-off Set – M2.5 Thread

[White Nylon Machine Screw and Stand-off Set – M2.5 Thread](https://www.adafruit.com/product/3658)
Totaling 420 pieces, this **White Nylon&nbsp;M2.5 Screw Set** &nbsp;is a must-have smörgåsbord for your workstation.&nbsp;You'll have more than enough screws, nuts, and hex standoffs to construct&nbsp;your maker projects&nbsp;for days on end! M2.5 screws fit nearly...

In Stock
[Buy Now](https://www.adafruit.com/product/3658)
[Related Guides to the Product](https://learn.adafruit.com/products/3658/guides)
### Conductive Nylon Fabric Tape - 5mm Wide x 10 meters long

[Conductive Nylon Fabric Tape - 5mm Wide x 10 meters long](https://www.adafruit.com/product/3961)
With our fun assortment of&nbsp;[conductive materials](https://www.adafruit.com/category/190),&nbsp;[cosplay](https://www.adafruit.com/index.php?main_page=category&cPath=290)&nbsp;and&nbsp;[wearables](https://www.adafruit.com/category/65)&nbsp;have never...

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

## Related Guides

- [Adafruit Circuit Playground Express](https://learn.adafruit.com/adafruit-circuit-playground-express.md)
- [Soil Moisture Sensor with Circuit Playground Express and MakeCode](https://learn.adafruit.com/soil-moisture-sensor-with-circuit-playground-express.md)
- [DIY Circuit Playground Shields](https://learn.adafruit.com/circuit-playground-shields.md)
- [Makecode para la Circuit Playground Express](https://learn.adafruit.com/makecode-es.md)
- [UFO Flying Saucer with Circuit Playground Express](https://learn.adafruit.com/ufo-circuit-playground-express.md)
- [Living Starry Night Painting](https://learn.adafruit.com/animated-starry-night-circuit-playground-express.md)
- [Welcome to CircuitPython!](https://learn.adafruit.com/welcome-to-circuitpython.md)
- [Easter Egg Light Stand](https://learn.adafruit.com/easter-egg-light-stand.md)
- [Circuit Playground Express Head-Tilt Ears](https://learn.adafruit.com/circuit-playground-express-head-tilt-ears.md)
- [Spinning Logo](https://learn.adafruit.com/spinning-logo.md)
- [Light Paintbrush with Circuit Playground](https://learn.adafruit.com/lightpaint-cplay.md)
- [CircuitPython Made Easy on Circuit Playground Express and Bluefruit](https://learn.adafruit.com/circuitpython-made-easy-on-circuit-playground-express.md)
- [NeoPixels with MakeCode](https://learn.adafruit.com/neopixels-with-makecode.md)
- [Fireflies with MakeCode](https://learn.adafruit.com/circuit-playground-fireflies-makecode.md)
- [LED Harness Bra](https://learn.adafruit.com/neopixel-led-harness-bra.md)
