Using a Lilypad for a first project

Create a Cushion with twinkling lights

This project is to make a cushion with twinkling lights. The light circuit was added to a cushion project during the making of the cushion. This blog assumes you have a cushion project or fabric to sew the circuit on.

This project uses the lilypad and circuit as a decorative feature and so it is sewed on the outside of the cushion. This will assist with changing the programming of the lights and replacing the battery. The cushion will be decorative and not washable.

You could do a similar project and hide the lilypad inside. Consider how will you change the battery.

You will need:
Fabric for your cushion - we made a 50cm cushion.
Conductive thread
Alligator clips or wire for each light
Needle
Embroidery hoop
Dress makers chalk
Download Arduino Software - https://www.arduino.cc/en/main/software 

Program the Lilypad
There are many ways to construct code. This was a first attempt and an easy way to teach beginners about parts of a program. If you would like to propose an alternative method of coding this please do so in the comments via links or text, make sure you include commenting.
  1. Open the Arduino Software
  2. Click on File, New.
  3. Copy the code from https://www.arduino.cc/en/tutorial/fade
    Instructions to sew in Lily Pad with 9 points. This project only uses 3.
  4. Paste it into your Arduino Sketch.
  5. Modify the code to adapt it for 3 pins. This project uses pins 9, 10 and 11
  6. Modify the Code to make 3 lights fade using pins 9, 10 and 11 see below.
  7. Click on the tick to compile the program.
    See troubleshooting if there is an error.
  8. Plug the lilypad to the USB port.
  9. Click on Tools, Board, Lilypad Arduino (to select the correct hardware).
  10. Click on Tools, Port, USB (to select the correct port).
  11. Click on the horizontal arrow on the toolbar.
    This will load the program onto the lilypad.
  12. It should Upload Complete. If the program has no orange lines at the bottom of the screen it has been successful.
    See trouble shooting if there is an error.
Troubleshooting
If there is error messages at the bottom
  1. Check the error message, missing ; or ,
  2. Check for incorrect capital letters.
  3. Check there are no spelling mistakes.
  4. Check for missing brackets
  5. Check the correct board is selected.
    Click on Tools, Board, Lilypad Arduino (to select the correct hardware).
  6. Check the correct port is selected.
    Click on Tools, Port, USB (to select the correct port).

Final Project Code
 /*Fade */
int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by

// the setup routine runs once when you press reset:
void setup() {
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);

}

// the loop routine runs over and over again forever:
void loop() {
  // set the brightness of pin 9:
  analogWrite(9, brightness);
  analogWrite(10, brightness);
  analogWrite(11, brightness);

// change the brightness for next time through the loop:
  brightness = brightness + fadeAmount;

  // reverse the direction of the fading at the ends of the fade:
  if (brightness <= 0 || brightness >= 255) {
    fadeAmount = -fadeAmount;
  }
  // wait for 30 milliseconds to see the dimming effect
  delay(30);
}

Hook up the circuit to test the program
Before you sew the circuit on the fabric it is important to hook it up and test the circuit this project used alligator clips, you could use wire to test the circuit.

You will need to snap the lilypad and 3 LEDs out of the prototyping frame. do this carefully so you don't damage the components.
  1. Plug in the battery to the lilypad.
  2. Clip one alligator clip to pin 9, on the lilypad.
  3. Clip the other end to the positive end of an LED. 
  4. Clip one alligator clip to pin 10, on the lilypad.
  5. Clip the other end to the positive end of an LED. 
  6. Clip one alligator clip to pin 11, on the lilypad.
  7. Clip the other end to the positive end of an LED.
  8. Clip one alligator clip to the negative terminal on the lilypad.
  9. Clip the other end to the negative end of the LED on pin 11. 
  10. Clip one alligator clip to the negative end on pin 11.
  11. Clip the other end to the negative end of the LED on pin 10. 
  12. Clip one alligator clip to the negative end on pin 10.
  13. Clip the other end to the negative end of the LED on pin 9.
  14. Turn on the lilypad.
If it doesn't work, check the positions of the clips, they are big and bulky for the small lights, they may have come off. Then check your program again.

Once you have tested the circuit and the lights come on you are ready to sew. 

Sew the Circuit
This project uses double thread to give more strength and more contact for the lights.
This blog talks about how to layout the lights. https://www.sparkfun.com/tutorials/312 
Each light is like spokes out from the lily pad to the positive terminal on the LED. Then you sew around the outside of the lights from the negative terminal on the lilypad to each negative point on each LED. You do not need to complete the circle there will be a gap between the last light and the lilypad, check the pictures in the sparkfun tutorial. (this may upset the OCD people but that is the way it is. If it upsets you too much you can complete the circuit using regular grey cotton to match the conductive thread.

BEWARE!!! 
  • Conductive thread tangles easily. 
  • You also want to ensure the thread is long enough to get to the next LED. 
  • You want to limit the number of ends and knots you have along the way as these increase the risk of the circuit breaking.
  • Do NOT cross over the path of conductive thread. Each line of stitching must be clear of any other part of the circuit.
Sew the Circuit
  1. Plan the location of your lights and lilypad.
  2. Plan the route the thread will take.
  3. Draw on the fabric with chalk if you need to - remember you can't wash it once the circuit is on.
  4. Use the embroidery hoop to put tension on the fabric as you sew.
  5. Sew the lily pad on to the fabric with grey thread in the pins you won't be using to reduce movement.
  6. With conductive thread sew into pin 9. Loop through the circle 3 times.
  7. Using running stitch sew to the position of the first LED.
  8. Sew into the positive terminal of the first LED.
  9. With conductive thread sew into pin 10. Loop through the circle 3 times.
  10. Using running stitch sew to the position of the second LED.
  11. Sew into the positive terminal of the second LED.
  12. With conductive thread sew into pin 11. Loop through the circle 3 times.
  13. Using running stitch sew to the position of the third LED.
  14. Sew into the positive terminal of the third LED, 3 times.
  15. With conductive thread sew into the negative pin on the lilypad. Loop through the circle 3 times.
  16. Using running stitch sew to the negative terminal of the first LED.
  17. Using running stitch sew to the negative terminal of the second LED.
  18. Using running stitch sew to the negative terminal of the third LED.
  19. Ensure the battery is turned on.
  20. Turn on the lilypad.
This project also included a pocket to securely store the battery. The pocket was placed just above the lilypad.