Components · 11 min read

LilyPad Arduino: Wearable Electronics with Conductive Thread

LilyPad Arduino wearables: conductive thread, sewable LEDs and sensors, LiPo vs CR2032, avoiding short circuits, washing and a light-up bag code example.

The LilyPad Arduino is a round, thin Arduino board designed to be sewn into fabric. Its pins sit around the edge as petals with holes big enough for a needle. Instead of soldering wires, you connect LEDs, sensors, buttons and batteries by stitching conductive thread around these holes. That lets you build wearable electronics projects such as a light-up costume, a bag that glows in the dark, a cycling jacket with turn signals or a bracelet that blinks with your pulse. Programming is the same as any Arduino; the difference is that the circuit lives on the fabric.

In this guide we'll cover the LilyPad board types, the properties of conductive thread and stitching technique, and sewable LED and sensor modules. We'll look at the difference between a LiPo battery and a CR2032 coin cell, ways to avoid short circuits while sewing and how to wash your garment. Then we'll write a sketch for a light-up bag that turns on in the dark and changes mode with a button, and compare alternatives such as the Gemma, Circuit Playground and ESP32.

LilyPad Arduino board
LilyPad Arduino: the large-holed pins around the edge are sewn into fabric with conductive thread.

What is the LilyPad Arduino, and what types are there?

LilyPad is the first family of sewable Arduino boards, designed by Leah Buechley at the MIT Media Lab and produced together with SparkFun. The main board is about 50 mm across and very thin, so it doesn't stand out inside a garment. Classic LilyPad boards use the same ATmega328P microcontroller as the Arduino Uno, but it runs at 8 MHz and can be powered from anything between 2.7 and 5.5 V. That means it runs directly from a 3.7 V LiPo battery. Classic boards have no USB socket; to upload code you use a 6-pin USB-TTL (FTDI) converter. The LilyPad Arduino USB, thanks to its ATmega32U4, is programmed directly over a USB cable.

BoardMicrocontrollerSewable pinsPower and connectionWhen to choose it
LilyPad Arduino 328 (main board)ATmega328P, 8 MHz14 digital (6 PWM), 6 analog2.7–5.5 V, programmed via FTDILarge projects with many LEDs and sensors
LilyPad Arduino SimpleATmega328P, 8 MHz9 pins: 5, 6, 9, 10, 11 and A2–A5JST LiPo socket, charging circuit and on/off switchBeginners and most battery projects
LilyPad Arduino USBATmega32U4, 8 MHz9 pins (4 PWM, 4 analog)Micro USB, JST battery socket, 3.3 VIf you want to upload code without FTDI
LilyTiny / LilyTwinkleATtiny854 pinsPreprogrammed, simple effectsSmall jobs that just light a few LEDs
If you're just starting out, the LilyPad Arduino Simple is the most practical choice: with fewer pins the sewing plan stays simple, you plug a LiPo battery into its JST socket, and the battery charges automatically while the FTDI converter is connected. When uploading code, choose LilyPad Arduino under Tools > Board in the Arduino IDE and ATmega328P as the processor.

Conductive thread and stitching technique

Conductive thread is usually made of stainless steel fibres or silver-plated nylon and is threaded through a needle and sewn like ordinary thread. Its biggest difference from wire is its resistance: a thin stainless steel thread has roughly 40–100 Ω per metre. On short signal lines that doesn't matter, but LEDs at the end of a long power line glow dimmer. So keep the plus (+) and minus (−) lines as short as possible, and if needed sew the same path twice to halve the resistance. Stainless steel thread survives washing; silver-plated thread conducts better but can tarnish over time.

FeatureStainless steel threadSilver-plated threadOrdinary wire
ResistanceRoughly 40–100 Ω/mLower, depends on thicknessVery low (milliohms)
WashingDurableCan tarnish over timeStiff in fabric
Ease of sewingA little stiff, knots easilySoft, easy to sewCan't be sewn, needs soldering
Best forMost wearable projectsLines that need high conductivityConnections off the fabric
  1. Draw your circuit on paper first, then on the fabric with tailor's chalk; mark the plus and minus lines in different colours.
  2. Lay the parts on the fabric; turn them so the plus petals face one side and the minus petals the other.
  3. Cut about 60–80 cm of thread; longer pieces tangle. Thread the needle and knot the end.
  4. Sew tightly 3–4 times around the hole in the board's petal; a loose loop lets the connection come undone.
  5. Move to the next part with short, even running stitches and sew 3–4 loops around its petal too.
  6. Tie two knots on the back of the fabric, cut the thread leaving 2–3 mm and seal the knot with clear nail polish or fabric glue.
  7. After finishing each line, check both ends with the multimeter's continuity mode; also check there's no continuity between neighbouring lines.
When a line is finished, cut the thread and use new thread for the next line. Carrying on from one line to the next with the same thread connects the two lines and causes a short. If the plus and minus lines have to cross or run very close, leave a layer of fabric between them, or run one on the back of the fabric and insulate it with fabric paint.

Sewable LEDs, sensors and other modules

The LilyPad family includes dozens of small modules designed to be connected with conductive thread. LilyPad LED boards already have a current-limiting resistor, so you don't need to sew one in; sew one petal to an Arduino pin and the other to the minus line. If you use an ordinary LED, you can curl its legs into loops and sew them, but don't forget a series resistor; find its value with the LED resistor calculator. Addressable LilyPad Pixel boards are WS2812-based and light up in any colour in a chain on a single signal line; we explained how they work in the WS2812B NeoPixel LED article.

ModuleConnectionUse
LilyPad LED+ petal: digital or PWM pin, − petal: minus lineLight patterns, indicators (resistor built in)
LilyPad Pixel (WS2812)+, −, data in and data outColourful, chainable effects
LilyPad light sensorS: analog pin (A2), +, −Turning on automatically in the dark
LilyPad temperature sensorS: analog pin, +, −Body or ambient temperature
LilyPad accelerometerX, Y, Z: analog pins, +, −Detecting motion and gestures
LilyPad button and slide switchOne petal to a pin, the other to minus (INPUT_PULLUP)Changing modes, on/off
LilyPad buzzer and vibe boardPin and minusSound and haptic feedback
LilyPad coin cell battery holder+ and −, with a switchSimple circuits with a few LEDs
WS2812B addressable LED
Addressable LEDs give wearable projects rich colour effects over a single data line.

Power: LiPo battery or CR2032?

In wearable projects the battery decides how long the project runs and how heavy it is. A CR2032 coin cell gives 3 V, is light and holds about 225 mAh, but it can only deliver a few milliamps continuously. A LilyPad board alone draws about 5 mA and each LED 5–10 mA, so in a circuit with an Arduino and a few LEDs the coin cell's voltage collapses quickly and the board resets. So use a CR2032 only in simple circuits with a few LEDs and no Arduino. For projects with an Arduino, a 3.7 V LiPo battery is the best choice: it's 4.2 V when full, around 3.0 V when empty, and fits the LilyPad's 2.7–5.5 V operating range perfectly.

BatteryVoltageCapacitySuitsWatch out
CR2032 coin cell3 VAbout 225 mAhSimple circuit with 1–3 LEDs and no ArduinoVoltage collapses at high current
2 × AAA battery holder3 VAbout 1000 mAhShort projects that don't need chargingHeavy and bulky
LiPo 3.7 V (110–1000 mAh)3.7 V (4.2 V full)Depends on choiceLED and sensor projects with a LilyPad ArduinoDon't bend or pierce; choose one with a protection circuit
USB power bank5 VThousands of mAhCostumes and stage outfits that stay lit for a long timeSome switch off at low current

Estimating run time is easy: the board draws 5 mA, five LEDs at an average of 7 mA draw 35 mA, about 40 mA in total. A 500 mAh LiPo runs this circuit for about 500 / 40 = 12.5 hours; in practice, at 80 percent efficiency, about 10 hours is realistic. For a detailed calculation, use the battery life calculator tool and the what does mAh mean article. If your LilyPad Simple has no charging circuit or you use another board, you can charge the LiPo safely with a TP4056 charging module.

Never sew, pierce, fold or put a LiPo battery where it can be crushed. Put the battery in a pocket or a small pouch with a snap and connect it with the JST socket. A damaged, swollen or hot LiPo can start a fire; choose batteries with a protection circuit.

Uploading code to the LilyPad

  1. In the Arduino IDE choose LilyPad Arduino under Tools > Board (LilyPad Arduino USB for the USB version).
  2. On the classic board choose ATmega328P in the Processor menu; older boards may have an ATmega168.
  3. Plug the 6-pin FTDI or USB-TTL converter into the 6-pin header on the board; line up the BLK or GND mark on the board with the converter's GND pin.
  4. Select the right port and press Upload; the converter's DTR line resets the board automatically during upload.
  5. On the LilyPad Arduino USB a micro USB cable is enough; if the port doesn't show up, reset the board and try uploading right away.
Test the code and circuit with alligator clips before sewing. Alligator clips grip the LilyPad's large holes easily; once the circuit works, start sewing. That way you won't have to unpick an LED sewn to the wrong pin.

Project: a light-up bag that glows in the dark

Our first project is a bag that turns on by itself when it gets dark. We sew five LilyPad LEDs on the front of the bag, a light sensor on the edge and a button on the inside. While the surroundings are bright, the LEDs stay off; when the light sensor value falls below the threshold, the LEDs light up according to the selected mode. Each button press changes the mode: off, steady, breathing and chasing light. The code doesn't use delay() and does its timing with millis(), so the button responds at any moment. For details of this method, see the Arduino millis vs delay article.

PartLilyPad Simple pinOther end
LilyPad LED 1–55, 6, 9, 10, 11Each LED's − petal to the shared minus line
LilyPad light sensorS → A2+ to the plus line, − to the minus line
LilyPad buttonOne petal to A5Other petal to the minus line
LiPo batteryJST socketIn a pocket or small pouch
C++ (Arduino IDE)
1// LilyPad Arduino ışıklı çanta: karanlıkta yanar, butonla mod değişir
2// LilyPad light-up bag: lights up in the dark, button changes the mode
3// LED'ler: 5, 6, 9, 10, 11 (PWM)  Işık sensörü: A2  Buton: A5
4const uint8_t ledler[] = {5, 6, 9, 10, 11};
5const uint8_t LED_SAYISI = sizeof(ledler);
6const uint8_t ISIK_PIN = A2;
7const uint8_t BUTON_PIN = A5;
8const int KARANLIK_ESIK = 300;     // 0-1023; kendi ortamında ölç / measure in your own room
9
10uint8_t mod = 1;                   // 0 kapalı, 1 sabit, 2 nefes, 3 yürüyen / off, steady, breathe, chase
11bool oncekiButon = HIGH;
12unsigned long sonBasma = 0;
13
14void hepsi(uint8_t deger) {
15  for (uint8_t i = 0; i < LED_SAYISI; i++) analogWrite(ledler[i], deger);
16}
17
18void setup() {
19  for (uint8_t i = 0; i < LED_SAYISI; i++) pinMode(ledler[i], OUTPUT);
20  pinMode(BUTON_PIN, INPUT_PULLUP);   // buton A5 ile eksi (-) arasında / button between A5 and minus
21}
22
23void loop() {
24  bool buton = digitalRead(BUTON_PIN);
25  if (oncekiButon == HIGH && buton == LOW && millis() - sonBasma > 200) {
26    mod = (mod + 1) % 4;              // sonraki mod / next mode
27    sonBasma = millis();
28  }
29  oncekiButon = buton;
30
31  bool karanlik = analogRead(ISIK_PIN) < KARANLIK_ESIK;
32  if (mod == 0 || !karanlik) {        // kapalı ya da aydınlık / off or bright
33    hepsi(0);
34    return;
35  }
36
37  unsigned long t = millis();
38  if (mod == 1) {
39    hepsi(150);                       // tam parlaklık değil, pil dostu / not full brightness, saves battery
40  } else if (mod == 2) {
41    unsigned int faz = t % 3000;      // 3 sn'lik nefes / 3-second breathing
42    uint8_t p = faz < 1500 ? faz * 255UL / 1500 : (3000 - faz) * 255UL / 1500;
43    hepsi(p);
44  } else {
45    uint8_t aktif = (t / 150) % LED_SAYISI;   // her 150 ms'de bir sonraki LED / next LED every 150 ms
46    for (uint8_t i = 0; i < LED_SAYISI; i++) analogWrite(ledler[i], i == aktif ? 255 : 0);
47  }
48}

The KARANLIK_ESIK (dark threshold) value in the code depends on the surroundings. First take readings with a short sketch that prints the sensor value to the Serial Monitor in a bright room and a dim corridor, then put the threshold between them. We explained the basics of light sensors in the LDR light sensor article; the LilyPad light sensor also gives a lower value in the dark. In breathing mode the brightness rises from zero to 255 and back every 3 seconds. Not running the LEDs at full brightness in any mode noticeably extends battery life.

Light sensor
The light sensor detects darkness; the LilyPad version has petals you can sew into fabric.

Avoiding short circuits while sewing

  • Plan the plus and minus lines along two separate edges of the fabric; leave at least 5 mm between them.
  • Cut knot tails to 2–3 mm and seal them with clear nail polish or fabric glue; loose fibres can touch a neighbouring line.
  • If lines must cross, run one on the back of the fabric, or put a layer of fabric or felt at the crossing point.
  • On stretchy fabrics (leggings, T-shirts) lines move closer as the stitches stretch; leave wider gaps on such fabric and sew a felt strip between lines if possible.
  • Before connecting the battery, measure between plus and minus with a multimeter; a value near zero means a short.
  • If the board or battery gets warm while the circuit is running, remove the battery at once and check the lines.

Washing and care

LilyPad boards and conductive thread are designed to survive water, but you need to follow the right method. Always remove the battery before washing; a circuit that gets wet while powered is damaged instantly. Wash the garment gently by hand in lukewarm water with a mild detergent; the spin cycle of a washing machine and the heat of a tumble dryer loosen stitches and stress the boards. After washing, lay the garment flat and let it dry completely on its own; don't connect the battery while there's still moisture inside, which usually takes about a day. The easiest approach is to attach the board and battery pouch to the fabric with conductive snaps, so you can remove the electronics before washing.

If you used silver-plated thread and ordinary LEDs, removing the electronics before washing matters even more. A design sewn with stainless steel thread and fitted with snaps lets you use the garment for many years.

Alternatives: Gemma, Circuit Playground and ESP32

The LilyPad isn't the only option. Adafruit's Gemma M0 is 28 mm across with only three pins, but it has a powerful 48 MHz processor and an RGB LED on the board; it's ideal for a small badge or earring. The Circuit Playground Express is a 50 mm sewable board with 10 addressable LEDs, light and temperature sensors, an accelerometer, a microphone, a speaker and two buttons on board; you can make a light-up costume without adding any parts. If you want Bluetooth, there's the Circuit Playground Bluefruit. For Wi-Fi control from a phone or an internet connection you can use small ESP32 boards (such as the XIAO ESP32-C3); they aren't designed for sewing, so you solder the board to a small piece of perfboard and sew the perfboard to the fabric.

BoardProcessorHighlightProgrammingSuits
LilyPad Arduino SimpleATmega328P, 8 MHz9 sewable pins, LiPo chargingArduino IDE (FTDI)General wearable projects
Gemma M0ATSAMD21, 48 MHz28 mm, 3 pins, built-in RGB LEDCircuitPython, Arduino IDEBadges, earrings, small accessories
Circuit Playground ExpressATSAMD21, 48 MHz10 LEDs, sensors, speaker, buttonsMakeCode, CircuitPython, Arduino IDECostumes without extra parts, education
Circuit Playground BluefruitnRF52840Bluetooth LECircuitPython, Arduino IDEGarments controlled from a phone
XIAO ESP32-C3 (on perfboard)ESP32-C3, 160 MHzWi-Fi and BLE, very smallArduino IDE, MicroPythonInternet-connected wearables

If you use CircuitPython on the Circuit Playground Express, you write the code in Python and the board shows up on your computer like a USB drive; you just save the file. In the example below the board lights up in the dark, changes colour with button A and gives a short white flash when shaken. The code uses the adafruit_circuitplayground library, which comes ready with the board's CircuitPython install.

Python
1# Circuit Playground Express (CircuitPython): karanlıkta yanan, sallanınca parlayan kostüm
2# Costume that lights up in the dark and sparkles when shaken
3import time
4from adafruit_circuitplayground import cp
5
6cp.pixels.brightness = 0.2            # pil tasarrufu / save battery
7renkler = [(255, 0, 60), (0, 120, 255), (255, 140, 0)]
8renk = 0
9
10while True:
11    if cp.button_a:                   # A butonu renk değiştirir / button A changes colour
12        renk = (renk + 1) % len(renkler)
13        time.sleep(0.3)
14    if cp.light < 30:                 # karanlık / dark
15        if cp.shake(shake_threshold=20):
16            cp.pixels.fill((255, 255, 255))   # sallanınca beyaz parıltı / white flash on shake
17            time.sleep(0.1)
18        cp.pixels.fill(renkler[renk])
19    else:
20        cp.pixels.fill((0, 0, 0))
21    time.sleep(0.05)

Wearable project ideas

  • Cycling jacket with turn signals: two buttons sewn on the sleeves and LED arrows on the back to show left and right turns.
  • Light-up costume: a stage or Halloween costume with chasing and breathing effects; use addressable LEDs for many colours.
  • Smart wristband: a band that counts steps or movement with an accelerometer and buzzes with a vibe board when you reach your goal.
  • Temperature-alert beanie: a winter hat whose LED colour changes when the temperature sensor detects cold.
  • Sound-reactive T-shirt: a party shirt that lights up to the beat of the music using a board with a microphone.

The LilyPad Arduino is a fun platform that brings electronics to a new audience by combining it with handicrafts. To try your circuit before sewing it into fabric, you can build the LED blink, chasing LED, Knight Rider, LDR night light, RGB LED and WS2812B projects in the BlueGrays app step by step with circuit diagrams and code, then move the working code to the LilyPad and sew it onto your garment.

Frequently asked questions

What is the LilyPad Arduino?

The LilyPad Arduino is a round, thin Arduino board designed to be sewn into fabric. Its pins are large-holed petals a needle can pass through, and parts are connected with conductive thread. It's used in wearable electronics projects such as light-up costumes, bags and bracelets.

How do you program a LilyPad Arduino?

Classic LilyPad boards are programmed with a 6-pin FTDI or USB-TTL converter. In the Arduino IDE you choose LilyPad Arduino as the board and ATmega328P as the processor. The LilyPad Arduino USB is programmed directly with a micro USB cable.

What is conductive thread and how much resistance does it have?

Conductive thread is a conductor made of stainless steel or silver-plated fibres that you sew like ordinary thread. Thin stainless steel threads have roughly 40–100 Ω per metre. That's why power lines should be kept short and, if needed, sewn twice.

What battery does the LilyPad Arduino use?

The LilyPad Arduino runs on 2.7–5.5 V, so a 3.7 V LiPo battery is the best choice. A CR2032 coin cell is only suitable for simple circuits with a few LEDs and no Arduino, because its voltage drops at higher current. A USB power bank also works for costumes that need to run for a long time.

Is the LilyPad Arduino washable?

LilyPad boards and stainless steel thread are designed to survive hand washing. Always remove the battery before washing, wash by hand with a mild detergent and don't reconnect the circuit until it's completely dry. The safest way is to attach the board with snaps and remove it before washing.

What board can I use instead of a LilyPad?

The Adafruit Gemma M0 is a good alternative for small accessories, and the Circuit Playground Express for costumes without extra parts, since its sensors and 10 LEDs are built in. If you need Wi-Fi or Bluetooth, use the Circuit Playground Bluefruit or a small ESP32 board.

See all projects
LED Blink
AR-1Beginner

LED Blink

The very first hello of electronics: switching a single LED on and off. The Arduino turns the LED on and off at short intervals, so the light blinks quickly.

4.6(200)
1246
Two LEDs Blinking Alternately
AR-2Beginner

Two LEDs Blinking Alternately

Two LEDs blink quickly in turn: when one lights up the other goes off, as if they were tossing a ball back and forth.

4.6(110)
362
LED Chaser
AR-5Intermediate

LED Chaser

Lights that switch on one after another, as if they were running. The Arduino lights six LEDs one at a time; each glows for a brief moment and goes out, so the light walks from start to end and then…

4.6(87)
218
Knight Rider LED Effect
AR-6Intermediate

Knight Rider LED Effect

The classic scanner light: a dot of light slides from one end of six LEDs to the other and then comes back.

4.8(107)
214
Measuring Light Intensity with an LDR
AR-11Beginner

Measuring Light Intensity with an LDR

Want to see how bright your room is as a number? The LDR, a small part that reacts to light, measures the light around it, and the Arduino writes the value to your computer screen every half second.

4.6(83)
143
Night Light with Ldr
AR-12Beginner

Night Light with Ldr

A little night light that turns on by itself when it gets dark and goes off when morning comes.

4.7(105)
224
Using an RGB LED
AR-39Beginner
Premium

Using an RGB LED

Three colours hide inside a single LED: the RGB LED lights up red, then green, then blue, each colour on for half a second and off for half a second, before the cycle starts again.

4.9(73)
100
Using a WS2812B LED Strip
AR-69Intermediate
Premium

Using a WS2812B LED Strip

Meet a smart LED strip where you can colour every single light on its own. The Arduino first lights the first five LEDs red, a second later turns the other five blue, then switches them all off and…

4.8(54)
70