LilyPad Safety Scarf

Contributors: Feldi
Favorited Favorite 5


Design and build time: 1 Day

In this project, we’ll create a wearable safety scarf. The safety scarf is embedded with LilyPad Hardware and a ribbon of LEDs. It is designed for pedestrians to increase visibility when walking the streets at night. The LED ribbon is triggered when light is low, making the wearer more visible to vehicles, bikers, and other pedestrians.

safety scarf

Suggested Reading

Before you get started, take some time to familiarize yourself with the following:

How to Solder: Through-Hole Soldering

This tutorial covers everything you need to know about through-hole soldering.

Working with Wire

How to strip, crimp, and work with wire.

Light-Emitting Diodes (LEDs)

Learn the basics about LEDs as well as some more advanced topics to help you calculate requirements for projects containing many LEDs.


An introduction to polarity in electronic components. Discover what polarity is, which parts have it, and how to identify it.

Insulation Techniques for e-Textiles

Learn a few different ways to protect your conductive thread and LilyPad components in your next wearables project.

Planning a Wearable Electronics Project

Tips and tricks for brainstorming and creating a wearables project.

LilyPad Basics: E-Sewing

Learn how to use conductive thread with LilyPad components.

LilyPad ProtoSnap Plus Hookup Guide

The LilyPad ProtoSnap Plus is a sewable electronics prototyping board that you can use to learn circuits and programming with Arduino, then break apart to make an interactive fabric or wearable project.

Getting Started with LilyPad

An introduction to the LilyPad ecosystem - a set of sewable electronic pieces designed to help you build soft, sewable, interactive e-textile projects.

In this project, we will also be following a free sewing pattern from Purl Soho which can be found here.

Materials and Tools

Let's go over all of the things you'll need to put your project together.

Learn more about e-sewing basic techniques here.

You Will Also Need:

Understanding Your Circuit

The LilyPad Safety Scarf is an example of a sewable embedded circuit. For this project, we will use a LilyPad USB Plus from the LilyPad ProtoSnap Plus and LilyPad Light Sensor (there is also one included on the ProtoSnap plus that can be used) as well as two LED Ribbons. This project will be powered with an 850 mAh LiPo battery.

As expressed in the circuit diagram below, the sewable microcontroller is connected to a sewable light sensor via conductive thread. The light sensor has three connections, VCC, GND, and 'S'. VCC and GND connect to '+' and '-', respectively. The 'S' tab should be connected to pin A2 on the microcontroller.

The LED ribbon will be handled differently. While the ribbon itself can be sewn onto a garment, the electrical leads are not sewable - just traditional wires. Luckily, the LilyPad Sew tabs are also solder friendly. So in this instance, we will solder the LED lead's soft, flexible wire to the microcontroller. The datasheet for the LED ribbon indicates that the anode is copper colored (i.e. reddish brown) and the cathode is a silver color (i.e. metallic grey). Connect the anode to pin 11 on the LilyPad USB Plus and the cathode to the GND pin labeled '-'.


Having a hard time seeing the circuit? Click on the wiring diagram for a closer look.

Software Installation

Arduino IDE

The LilyPad USB Plus is programmable via the Arduino IDE. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE.

Installing Arduino IDE

March 26, 2013

A step-by-step guide to installing and testing the Arduino software on Windows, Mac, and Linux.

LilyPad USB Plus and Board Add-On

If this is your first time working with the LilyPad ProtoSnap Plus, you will need to add the board through the boards manager to your program. Please visit the LilyPad ProtoSnap Plus hookup guide for detailed instructions on installing drivers and programming a LilyPad via the Arduino IDE.

Heads up! The correct selection in the boards manager is the LilyPad USB Plus. The LilyPad USB Arduino is an different version of this board and, if selected, will not upload correctly to the LilyPad USB Plus.

Arduino Program

Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE.

We have provided the code for this project below. Copy and paste it into your Arduino IDE and then upload it to your board. Make sure you have the correct board selected in the boards manager as well as the port under the port drop down.

//Melissa Felderman for SparkFun Electronics 2017

//variable for sensor pin
int sensorPin = A2;

//variable for light value
int lightValue;

//variable for LEDPin
int LEDPin = 11; 

void setup()
    // Set sensorPin as an INPUT
    pinMode(sensorPin, INPUT);

    //set LEDPin as OUTPUT
    pinMode(LEDPin, OUTPUT);

void loop()

   // Get the current light level
    lightValue = analogRead(sensorPin);

    //if light level is low, turn LEDS on
    if(lightValue <= 15){
      digitalWrite(LEDPin, HIGH);

    //if light is high, turn LEDs off
    else {
      digitalWrite(LEDPin, LOW); 



Putting It Together


Use an X-Acto Knife to cut the fabric around the LEDs back about one inch on one side of both of your LED ribbons.

step 1


This will cause the ribbon to fray at the end.

step 2

Pull back the wires and use a pair of scissors to cut off the frayed material. Make sure not to cut the LED's wires.

step 2


Apply Fray Check to the cut edge of each ribbon, and let it dry (~15 minutes).

step 3


Strip the exposed wire of LED strip. Notice one lead has a copper tint and one does not. The copper tinted lead is the anode, or '+' lead. For more information about polarity and LEDs, visit our tutorials about polarity and LEDs.

step 4


Solder the two LED ribbons together. This can be tricky with the LED ribbons since there is no room to add heat shrink and the frayed wires can easily become crossed. To battle this, I soldered my anodes first and left a little space between the two ribbons. Then, I insulated them with hot glue before soldering the cathodes together. Make sure to insulate the cathode side after soldering them together.

step 5


Cut a small rectangle of white felt. Fold it over the ribbon to hide the solder connections we just made. Hot glue it in place.

step 6


You should have one long LED ribbon now. Repeat steps 1-4 on only one end of the new long ribbon. Cut about two 4-5 inch pieces of flexible silicone wire, soldering one to the exposed anode and one to the exposed cathode.

step 7

Insulate with heat shrink and then set aside for later.

step 7


Cut your fabric according to the pattern. We used this lovely and easy to follow free cowl pattern by Purl Soho.

step 8


Sew the lining pieces together. Then sew the outer pieces together, but stop before sewing the lining and the outer fabric together. Set the lining aside for later.

step 9

STEP 10:

Find the "right side" of the outer fabric. The right side is the side that will be facing the world when you wear the garment. Grab the LED ribbon, and pin it to the long edge of your outer fabric on the right side. The sew tab should be along the top edge of the fabric with the tube holding the LED strip pointing towards the center of the fabric as seen in the image below.

step 10

STEP 11:

When you reach the end of your fabric edge, cut the strip to the same length of the fabric.

step 11

STEP 12:

Add a touch of Fray Check to the edge of LED ribbon that you cut.

step 12

STEP 13:

Sew the LED ribbon down along the sew tab. Make sure to remove the pins as you go since this can break your sewing machine needle and cause problems with your stitch. When using a sewing machine, be careful to not sew into the LEDs and wires.

step 13

STEP 14:

Add a dab of hot glue to the bottom of your LilyPad Light Sensor and then place it on the right side of your fabric about an inch below the LED ribbon leads.

step 14

step 14

STEP 15:

Flip the fabric over to the "wrong side." The wrong side will be the inside of the cowl. Add some hot glue to the bottom of the LilyPad USB Plus and place it down about 1-2 inches below the light sensor (but on the opposite side!)

step 15

step 15

STEP 16:

Using conductive thread, sew the light sensor to the microcontroller according to the circuit diagram.

step 16

STEP 17:

Strip the un-soldered side of both flexible silicone wires connected to the LED leads.

step 17

STEP 18:

Solder the anode ('+') lead connection to pin 11 on the LilyPad and the cathode ('-') lead to GND on the LilyPad.

step 18

STEP 19:

Cut a small hole directly above the USB cable connector. Make sure it is large enough to access that port from the opposite side of the fabric.

steo 19

step 19

STEP 20:

Apply Fray Check around the cut edges of the hole. Make sure that the Fray Check does not get into the USB connector.

step 20

STEP 21:

Trim the excess conductive thread and test your circuit with a battery. Once everything is working, use some puff paint to insulate the traces on both the right and wrong side of the fabric.

step 21

STEP 22:

Place your battery on the iron-on adhesive and trace it.

step 22

STEP 23:

Draw a larger rectangle around the battery's trace and leave at least a half inch space between the lines.

step 23

STEP 24:

Cut along the edge of the larger rectangle, and then cut out the battery tracing as well.

step 24

step 24

STEP 25:

With the paper side up, iron the iron-on adhesive to a scrap piece of fabric. Then cut the fabric along the edge of the adhesive.

step 25

step 25

STEP 26:

Peel the paper backing off of the iron-on adhesive.

step 26

STEP 27:

Plug your battery into the LilyPad's JST connector.

step 27

STEP 28:

Place the piece of fabric with the iron-on adhesive over of the battery. Make sure that the adhesive side is facing down.

step 28

STEP 29:

Being extremely careful to not touch the battery, and iron over the fabric where there is adhesive in order to make a battery holder.

CAUTION Heat should never be applied to directly to the battery. Use extreme caution whith the iron around the battery. If your hand is less steady, make the area around the battery larger, so you have more room between the adhesive and the battery itself. As an alternative, you can also sew the battery holder down.

step 29

STEP 30:

Finish sewing the scarf according to the pattern.

step 30

STEP 31:

Use your finger to feel for the ON/OFF switch on the LilyPad and then cut a small hole in the lining fabric to expose it.

step 31

STEP 32:

Add some Fray Check around the edge of the hole, and let dry.

step 32

STEP 33:

Turn it on by flipping the switch and enjoy!

final product

final product

final products

Resources and Going Further

Looking for another project? Check out these similar projects for inspiration!

Marquee Party Bag

This tutorial provides everything you need to know to make your own Marquee Party Bag!

Fairy LED Bracelet

Light up the world - and your wrist - with this quick and easy rechargeable firefly LED bracelet.

LED PomPom Headbands

Follow this tutorial to make your own light up PomPom headband! Try the beginner version if you are new to electronics or the advanced version if you have some more experience!

Twinkle Zodiac Constellation

Create a quick and easy piece of e-textile art based on a Zodiac sign using a LilyTiny, LilyPad LEDs, battery holder, conductive thread, and coin cell battery.