Light-Activated Pixel Heart

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.


To keep up with what I’m working on, follow me on YouTubeInstagramTwitterPinterest, and subscribe to my newsletter. As an Amazon Associate I earn from qualifying purchases you make using my affiliate links.

Circuit Diagram

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

The photoresistor is attached to D2 and GND.

Stitch Circuit

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.

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.

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.

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.

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.

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.

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…

Arduino Code

If this is your first time using GEMMA, work through the 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: Arduino Library Installation

Plug in your circuit and load up the sketch below:

// SPDX-FileCopyrightText: 2017 Limor Fried for Adafruit Industries
// SPDX-License-Identifier: MIT

#include <Adafruit_NeoPixel.h>

#define NUM_LEDS 8  // This many NeoPixels...
#define LED_PIN  1  // are connected to this DIGITAL pin #
#define SENSOR   2  // Light sensor to this DIGITAL pin #

Adafruit_NeoPixel strip(NUM_LEDS, LED_PIN);

void setup() {
  strip.begin();;                  // Initialize all pixels to 'off'
  pinMode(SENSOR, INPUT_PULLUP); // Enable pull-up resistor on sensor pin

void loop() {
  // The LDR is being used as a digital (binary) sensor, so it must be
  // COMPLETELY dark to turn it off, your finger is not opaque enough!
  if(!digitalRead(SENSOR)) {                 // Sensor exposed to light?
    colorWipe(strip.Color(255, 0, 255), 50); // Animate purple
  } else {                                   // else sensor is dark
    colorWipe(strip.Color(0, 0, 0), 50);     // Animate off
  delay(2); // Pause 2 ms before repeating

// Fill pixels one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
    strip.setPixelColor(i, c);;

Stitch Circuit Part 2

Let’s test before finishing the sewing. 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.

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.

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

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!

Originally posted on Adafruit.

You may be interested in some of my other work:

To keep up with what I’m working on, follow me on YouTubeInstagramTwitterPinterest, and subscribe to my newsletter.