Overview

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.

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.

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.
Upload the code included below to read data from a dependent resistor, aka LDR, aka photocell. If this is your first GEMMA project, don't forget to read our Introducing GEMMA guide to get your software up and running.

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.
#include <Adafruit_NeoPixel.h>

#define PIN 1
#define SENSOR 0

// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(8, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  //Serial.begin(9600); 
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
  pinMode(SENSOR, INPUT); //set the sensor pin to an input
  // ...with a pullup
  digitalWrite(SENSOR, HIGH);
}

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)) {  // if the sensor is exposed to light
  colorWipe(strip.Color(255, 0, 255), 50); // animate purple

    } else { //if the sensor is dark
  colorWipe(strip.Color(0, 0, 0), 50); // animate off
    }
    delay(2); 
}


// Fill the dots 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);
      strip.show();
      delay(wait);
  }
}
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!

Circuit Diagram

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.