# Light-Activated Pixel Heart

## Overview

http://www.youtube.com/watch?v=k_AdfEPK0XQ

Wear your heart on your sleeve! Or at least on your lapel. This light-up heart display uses a light-dependent resistor and GEMMA, Adafruit's tiny wearable electronics platform.

![](https://cdn-learn.adafruit.com/assets/assets/000/014/590/medium800/gemma_becky-stern-werable-heart.jpg?1393445130)

Info: 

# Light-Activated Pixel Heart

## Stitch Circuit

https://www.youtube.com/watch?v=eGtGoPhjmcc

Place a piece of woven fabric in a 6-inch or larger embroidery hoop.  
  
Arrange eight sewable NeoPixels in a heart on your fabric.  
  
Trace around your pixels with a pencil or a disappearing-ink embroidery pen.

![gemma_pixel-heart-adafruit-00.jpg](https://cdn-learn.adafruit.com/assets/assets/000/014/330/medium640/gemma_pixel-heart-adafruit-00.jpg?1392400946)

![gemma_pixel-heart-adafruit-01.jpg](https://cdn-learn.adafruit.com/assets/assets/000/014/331/medium640/gemma_pixel-heart-adafruit-01.jpg?1392401244)

Start stitching the data lines between each pixel according to the circuit diagram. Begin by bringing the thread from back to front, leaving a 6-inch tail, and stitching around the inward facing arrow of one pixel, piercing through the fabric from front to back. Repeat a few times to secure the pixel to the fabric. Tie the tail in a knot with the working thread at the back.

![gemma_pixel-heart-adafruit-02.jpg](https://cdn-learn.adafruit.com/assets/assets/000/014/332/medium640/gemma_pixel-heart-adafruit-02.jpg?1392401304)

![gemma_pixel-heart-adafruit-03.jpg](https://cdn-learn.adafruit.com/assets/assets/000/014/341/medium640/gemma_pixel-heart-adafruit-03.jpg?1392408366)

![gemma_pixel-heart-adafruit-04.jpg](https://cdn-learn.adafruit.com/assets/assets/000/014/342/medium640/gemma_pixel-heart-adafruit-04.jpg?1392409431)

Use a running stitch to make your way to the outward-facing arrow on the next pixel, using your trace marks for guidance in pixel placement.   
  
After you've stitched around the pixel's pad a few times, tie the thread in a knot at the back.  
  
Apply tension to thread tails and dab clear nail polish onto the knots.  
  
Allow to dry, periodically tugging on the thread tails to keep the knots tight.  
  
Only clip thread tails short when completely dry to prevent unraveling!  
  
Continue making short connections between each pixel's data connections, making sure the arrows all point in the same direction along the chain. Refer to the circuit diagram.

![gemma_pixel-heart-adafruit-05.jpg](https://cdn-learn.adafruit.com/assets/assets/000/014/344/medium640/gemma_pixel-heart-adafruit-05.jpg?1392409556)

![gemma_pixel-heart-adafruit-06.jpg](https://cdn-learn.adafruit.com/assets/assets/000/014/345/medium640/gemma_pixel-heart-adafruit-06.jpg?1392409659)

![gemma_pixel-heart-adafruit-07.jpg](https://cdn-learn.adafruit.com/assets/assets/000/014/346/medium640/gemma_pixel-heart-adafruit-07.jpg?1392412815)

![gemma_pixel-heart-adafruit-08.jpg](https://cdn-learn.adafruit.com/assets/assets/000/014/347/medium640/gemma_pixel-heart-adafruit-08.jpg?1392412902)

Use a running stitch to trace around the perimeter of the heart, connecting to each pixel's power (+) pad as you go. Connect this thread to Vout on GEMMA at the back.  
  
Use another thread and running stitch to connect up all the ground (-) pads of the pixels, circling the inner perimeter of the heart. Connect this thread to GND on GEMMA at the back.  
  
Connect the first pixel's inward-facing arrow to D1 on GEMMA.  
  
Tie off and seal all knots before trimming thread tails.  
  
Put a piece of tape or fabric behind GEMMA where it overlaps any stitches it shouldn't touch.

![gemma_pixel-heart-adafruit-09.jpg](https://cdn-learn.adafruit.com/assets/assets/000/014/348/medium640/gemma_pixel-heart-adafruit-09.jpg?1392413063)

![gemma_pixel-heart-adafruit-10.jpg](https://cdn-learn.adafruit.com/assets/assets/000/014/349/medium640/gemma_pixel-heart-adafruit-10.jpg?1392416324)

![gemma_pixel-heart-adafruit-14.jpg](https://cdn-learn.adafruit.com/assets/assets/000/014/351/medium640/gemma_pixel-heart-adafruit-14.jpg?1392417266)

Use a multimeter in continuity-testing mode to test out your circuit. Make sure power isn't connected to ground, and verify that all points that should be connected are, indeed, connected.

![gemma_pixel-heart-adafruit-15.jpg](https://cdn-learn.adafruit.com/assets/assets/000/014/385/medium640/gemma_pixel-heart-adafruit-15.jpg?1392651305)

![gemma_pixel-heart-adafruit-16.jpg](https://cdn-learn.adafruit.com/assets/assets/000/014/386/medium640/gemma_pixel-heart-adafruit-16.jpg?1392673751)

Plug in the USB cable and test out the pixels using the **strandtest** sketch included in the Adafruit NeoPixel library for Arduino (change the value of PIN to **1** before compiling).  
  
Are they all working? Great! If not, unplug and re-evaluate your circuit. Clean up any frayed or loose bits of thread, re-stitch any loose spots and double-seal your knots. Probe again with your multimeter before reconnecting via USB.  
  
If you're happy with the flashing lights, you're done! Sew your new circuit swatch into a brooch or onto your Valentine's outfit, and rock your new flashy accessory.  
  
But if you want your heart to turn on only when the moment's right, continue on to add a light sensor, perfect for revealing your heart from under a jacket, hat, or hemline.

![gemma_pixel-heart-adafruit-17.jpg](https://cdn-learn.adafruit.com/assets/assets/000/014/387/medium640/gemma_pixel-heart-adafruit-17.jpg?1392676656)

![gemma_pixel-heart-adafruit-18.jpg](https://cdn-learn.adafruit.com/assets/assets/000/014/388/medium640/gemma_pixel-heart-adafruit-18.jpg?1392676709)

The circuit isn’t finished yet, but let’s get the final code onto the board before continuing, so we can test it along the way…

# Light-Activated Pixel Heart

## Arduino Code

Info: 

If this is your first time using GEMMA, work through the [Introducing G](http://learn.adafruit.com/introducing-gemma)[EMMA](http://learn.adafruit.com/introducing-gemma) guide first; you need to customize some settings in the Arduino IDE. Once you have it up and running (test the 'blink' sketch), then follow the instructions on the following page for installing the NeoPixel library:

## **[NeoPixel Überguide:&nbsp;Arduino Library Installation](../../../../adafruit-neopixel-uberguide/arduino-library-installation)**

Plug in your circuit and load up the sketch below:

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Light_Activated_Pixel_Heart/Light_Activated_Pixel_Heart.ino

# Light-Activated Pixel Heart

## CircuitPython Code

![](https://cdn-learn.adafruit.com/assets/assets/000/046/880/medium800/adafruit_gemma_CircuitPython-Gemma-w-Blinka.jpg?1506977571)

 **GEMMA&nbsp;M0** boards can&nbsp;run **CircuitPython** &nbsp;— a different approach to programming compared to Arduino sketches. In fact, **CircuitPython comes&nbsp;factory pre-loaded on GEMMA&nbsp;M0**. If you’ve overwritten it with an Arduino sketch, or just want to learn the basics of setting up and using CircuitPython, this is explained in the [**Adafruit GEMMA&nbsp;M0 guide**](../../../../adafruit-gemma-m0/circuitpython-setup-1).

Info: 

Below is CircuitPython code that works&nbsp;similarly (though not exactly the same) as the Arduino sketch shown on a prior page. To use this, plug the GEMMA M0 into USB…it should show up on your computer as a small **flash drive** …then edit the file “ **main.py** ” with your text editor of choice. Select and copy the code below and paste it into that file, **entirely replacing its contents** (don’t mix it in with lingering bits of old code). When you save the file, the code should **start running almost immediately** &nbsp;(if not, see notes at the bottom of this page).

**If GEMMA M0 doesn’t show up as a&nbsp;drive, follow the GEMMA M0 guide link above to prepare the board for CircuitPython.**

This code requires the **neopixel.py** library. A factory-fresh board will have this already installed. If you’ve just reloaded the board with CircuitPython, create the “lib” directory and then [download neopixel.py from Github](https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel).

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

# Light-Activated Pixel Heart

## Stitch Circuit Part 2

Let's test before finishing the sewing.&nbsp;Use **alligator clips** to connect one leg of the photocell to D0 on GEMMA and the other to GND.  
  
The pixels should animate pink when the sensor is exposed to light. Likewise they should turn off when the sensor is covered and completely dark.

![adafruit_gemma_gemma_pixel-heart-adafruit-19.jpg](https://cdn-learn.adafruit.com/assets/assets/000/046/881/medium640/adafruit_gemma_gemma_pixel-heart-adafruit-19.jpg?1506979294)

![adafruit_gemma_gemma_pixel-heart-adafruit-20.jpg](https://cdn-learn.adafruit.com/assets/assets/000/046/882/medium640/adafruit_gemma_gemma_pixel-heart-adafruit-20.jpg?1506979330)

![adafruit_gemma_gemma_pixel-heart-adafruit-21.jpg](https://cdn-learn.adafruit.com/assets/assets/000/046/883/medium640/adafruit_gemma_gemma_pixel-heart-adafruit-21.jpg?1506979370)

![adafruit_gemma_gemma_pixel-heart-adafruit-22.jpg](https://cdn-learn.adafruit.com/assets/assets/000/046/884/medium640/adafruit_gemma_gemma_pixel-heart-adafruit-22.jpg?1506979411)

To attach the LDR permanently, twist the ends of the leads into spirals as shown and paint the straight parts with nail polish-- it will insulate the LDR from the traces of conductive thread.  
  
Stitch one spiral to the GND line around the inner perimeter of the heart (all GNDs are connected), and the other to D0 on GEMMA.  
  
Toe knots and seal as before, then clip tails.

![adafruit_gemma_gemma_pixel-heart-adafruit-23.jpg](https://cdn-learn.adafruit.com/assets/assets/000/046/860/medium640/adafruit_gemma_gemma_pixel-heart-adafruit-23.jpg?1506969484)

![adafruit_gemma_gemma_pixel-heart-adafruit-24.jpg](https://cdn-learn.adafruit.com/assets/assets/000/046/861/medium640/adafruit_gemma_gemma_pixel-heart-adafruit-24.jpg?1506969587)

![adafruit_gemma_gemma_pixel-heart-adafruit-25.jpg](https://cdn-learn.adafruit.com/assets/assets/000/046/862/medium640/adafruit_gemma_gemma_pixel-heart-adafruit-25.jpg?1506969669)

![adafruit_gemma_gemma_pixel-heart-adafruit-26.jpg](https://cdn-learn.adafruit.com/assets/assets/000/046/864/medium640/adafruit_gemma_gemma_pixel-heart-adafruit-26.jpg?1506969771)

Test your new components' connections to GEMMA with a multimeter. If everything checks out, plug in your battery and pat yourself on the back!

![adafruit_gemma_gemma_pixel-heart-adafruit-27.jpg](https://cdn-learn.adafruit.com/assets/assets/000/046/865/medium640/adafruit_gemma_gemma_pixel-heart-adafruit-27.jpg?1506969884)

![adafruit_gemma_gemma_pixel-heart-adafruit-28.jpg](https://cdn-learn.adafruit.com/assets/assets/000/046/867/medium640/adafruit_gemma_gemma_pixel-heart-adafruit-28.jpg?1506969997)

![adafruit_gemma_gemma_pixel-heart-adafruit-29.jpg](https://cdn-learn.adafruit.com/assets/assets/000/046/868/medium640/adafruit_gemma_gemma_pixel-heart-adafruit-29.jpg?1506970084)

# Light-Activated Pixel Heart

## Wear it!

Take your circuit out of the embroidery hoop and finish the edge however you like. We sewed on a backing piece of fabric to enclose the circuit, and attached a pinback to wear it as a brooch.  
  
Under a jacket the circuit remains off, then when you reveal it, the heart animates on!

![](https://cdn-learn.adafruit.com/assets/assets/000/014/589/medium800/gemma_becky-stern-werable-heart.jpg?1393445106)

# Light-Activated Pixel Heart

## Circuit Diagram

![](https://cdn-learn.adafruit.com/assets/assets/000/022/629/medium800/gemma_pixelheart-diagram.jpg?1421874784)

NeoPixels are chained together with data input coming from GEMMA D1, all + to Vout and all - to GND.

Photoresistor is attached to D2 and GND.


## Featured Products

### Adafruit GEMMA v2 - Miniature wearable electronic platform

[Adafruit GEMMA v2 - Miniature wearable electronic platform](https://www.adafruit.com/product/1222)
 **Deprecation Warning: The Gemma bit-bang USB technique it uses doesn't work as well as it did in 2014, many modern computers won't work well. So while we still carry the Gemma so that people can maintain some older projects, we no longer recommend it.** <a...></a...>

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/1222)
[Related Guides to the Product](https://learn.adafruit.com/products/1222/guides)
### Adafruit GEMMA M0 - Miniature wearable electronic platform

[Adafruit GEMMA M0 - Miniature wearable electronic platform](https://www.adafruit.com/product/3501)
The **Adafruit Gemma M0** is a super small microcontroller board, with just enough built-in to create many simple projects. It may look small and cute: round, about the size of a quarter, with friendly alligator-clip sew pads. But do not be fooled! The Gemma M0 is incredibly...

In Stock
[Buy Now](https://www.adafruit.com/product/3501)
[Related Guides to the Product](https://learn.adafruit.com/products/3501/guides)
### Flora RGB Smart NeoPixel version 3 - Pack of 4

[Flora RGB Smart NeoPixel version 3 - Pack of 4](https://www.adafruit.com/product/1260)
What's a wearable project without LEDs? Our favorite part of the Flora platform is these tiny smart pixels. Designed specifically for wearables, these updated Flora NeoPixels have ultra-cool technology: these ultra-bright LEDs have a constant-current driver cooked right into the LED...

In Stock
[Buy Now](https://www.adafruit.com/product/1260)
[Related Guides to the Product](https://learn.adafruit.com/products/1260/guides)
### Lithium Ion Polymer Battery - 3.7v 100mAh

[Lithium Ion Polymer Battery - 3.7v 100mAh](https://www.adafruit.com/product/1570)
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 ~100mAh for a total of about 0.4 Wh. If you need a larger battery, <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/1570)
[Related Guides to the Product](https://learn.adafruit.com/products/1570/guides)
### Adafruit Micro Lipo - USB LiIon/LiPoly charger

[Adafruit Micro Lipo - USB LiIon/LiPoly charger](https://www.adafruit.com/product/1304)
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 3.7V/4.2V lithium polymer or lithium ion rechargeable battery into the JST plug on the other end. There are...

In Stock
[Buy Now](https://www.adafruit.com/product/1304)
[Related Guides to the Product](https://learn.adafruit.com/products/1304/guides)
### Photo cell (CdS photoresistor)

[Photo cell (CdS photoresistor)](https://www.adafruit.com/product/161)
CdS cells are little light sensors. As the squiggly face is exposed to more light, the resistance goes down. When it's light, the resistance is about ~1KΩ, when dark it goes up to ~10KΩ.

To use, connect one side of the photocell (either one, it's symmetric) to power...

In Stock
[Buy Now](https://www.adafruit.com/product/161)
[Related Guides to the Product](https://learn.adafruit.com/products/161/guides)
### Pocket Autoranging Digital Multimeter

[Pocket Autoranging Digital Multimeter](https://www.adafruit.com/product/850)
When we're on the go, we like to keep a multimeter in our purse and this model is by far the best pocket meter we've found. It's so good you'll end up using it as your main multimeter!  
  
First up, this meter can measure nearly everything: it's got DC and AC...

In Stock
[Buy Now](https://www.adafruit.com/product/850)
[Related Guides to the Product](https://learn.adafruit.com/products/850/guides)
### Gemma M0 Starter Pack

[Gemma M0 Starter Pack](https://www.adafruit.com/product/1657)
Get started with Adafruit GEMMA with this lovely starter kit! Included is everything you need to make a basic project.&nbsp;There's a GEMMA M0, four sewable bright RGB pixels, a battery holder (coin cell batteries not included), 2-ply conductive thread, alligator clips to help you test...

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

## Related Guides

- [Trinket / Gemma IR Control](https://learn.adafruit.com/trinket-gemma-ir-remote-control.md)
- [Serial Debugging with GEMMA](https://learn.adafruit.com/serial-debugging-with-gemma.md)
- [Wireless Control Button for WLED Projects](https://learn.adafruit.com/wireless-control-button-for-wled-projects.md)
- [LED NeoPixel Corset with Circuit Playground Express and MakeCode](https://learn.adafruit.com/led-corset-with-circuit-playground-and-makecode.md)
- [CircuitPython 101: Basic Builtin Data Structures](https://learn.adafruit.com/basic-datastructures-in-circuitpython.md)
- [Building CircuitPython](https://learn.adafruit.com/building-circuitpython.md)
- [Energy Budgets](https://learn.adafruit.com/energy-budgets.md)
- [Animated NeoPixel Glow Fur Scarf](https://learn.adafruit.com/animated-neopixel-gemma-glow-fur-scarf.md)
- [How to Choose a Microcontroller](https://learn.adafruit.com/how-to-choose-a-microcontroller.md)
- [A NeoPixel Blinkendisc](https://learn.adafruit.com/a-neopixel-blinkendisc.md)
- [NeoPixel Tiara](https://learn.adafruit.com/neopixel-tiara.md)
- [Glowing Skullcandy Headphones Mod](https://learn.adafruit.com/glowing-skullcandy-headphones-mod.md)
- [NeoPixel Punk Collar](https://learn.adafruit.com/neopixel-punk-collar.md)
- [NeoPixel Basketball Hoop](https://learn.adafruit.com/neopixel-mini-basketball-hoop.md)
- [NeoPixel Fairy Crown](https://learn.adafruit.com/neopixel-fairy-crown.md)
