Introduction: Slow-to-fast Twinkling Stars Blanket (using Conductive Patches)

I've always been fascinated by stars and constellations, so I thought I would attempt to make a big dipper + little dipper blanket that actually twinkles! 


I only used 6 LEDs, so not all the stars light up. When the blanket is turned on, the 6 lights blink. I programmed it so that the lights turn on one at a time. When the two conductive patches (made of tin foil and hidden under fabric stars) are touched, the speed of the lights increases. The harder they're pressed, the faster they twinkle (from 1 second pauses to 3/10 second pauses).

Step 1: Supplies

1. Fleece blanket, purchased or self-made, any size
2. Fabric, felt or fleece for stars and moon
3. Conductive thread
4. Lilypad Arduino USB ($24.95)
5. Battery, 3.7 V Li-ion 110mAH ($4.95)
6. Lilypad LEDs (6), any colors
7. Sewable velcro
8. Embroidery floss
9. Stuffing
10. Patience :)

Step 2: Circuit Diagram

I'm hoping you can find this diagram useful. I changed the color of the thread paths so it would be clear which paths had a negative charge vs. a positive charge. The Lilypad Arduino is obviously not to scale, but I enlarged it so that the pin titles could be better seen.

Step 3: Cut Stars, Lay Out Blanket

1. Cut out your fabric/felt/fleece into star shapes. I used an image of a star that I found on Google and traced it onto my fabric before cutting so that my stars would be symmetrical. I also enlarged the shape so that I would have two different sizes of stars, some larger than others.
2. Apply an adhesive sheet to the back of a sheet of tin foil. Using the same star pattern, cut out star shapes from the tin foil.
2. Lay out your stars and mark where your LEDs will go. 
3. Place your Lilypad.
4. With the exception of the stars that will cover LEDs, pin your stars down so they won't move.

Step 4: Start Sewing!

Following the circuit diagram, start sewing the LEDs to their Lilypad pins. When it comes time to sew to the tin foil patches, make sure you sew at least 2-3 inches worth into the foil so the connection will be strong enough. 

***Tip: Make sure your stitches throughout the blanket are strong. Do not stitch loosely. You might be tempted to sew sloppily because of the amount of sewing required, but be wary -- sloppy stitches result in weaker connections. Because the thread is traveling long distances, strength is key so that connection won't be lost!

***Tip: Make sure none of your threads cross. The positive and negative threads should never touch. Be especially careful on the back of the blanket. When I first made this, some of my LEDs didn't work and it turned out to be a loose thread on the back of the blanket. 

Step 5: Code and Test Your Lights

The lights were coded using Arduino, which can be downloaded for free. I've attached my code below. As you'll see, the blanket is programmed so that different levels of sensor readings change the light patterns. More specifically, the lower the reading (which equates to the higher the pressure placed on the patches) the quicker the twinkle pace.

Before you can set ranges in your code, you'll need to find out what sort of ranges your tin foil patches are detecting. In my code, the ranges varied from the 700s to nearly 1000. Size of your patches and the conductivity of your skin might vary the ranges your patches detect.

Once your patches are properly sewn, and your Lilypad is connected to your computer using a USB cord, you can test the ranges of your patches by clicking on the serial monitor button in the upper right corner of your Arduino code. Make sure the proper USB is identified in tools -> serial port, and that the right Lilypad board is selected in tools -> board.

Your code should include the following for the serial monitor test to work:

int aluminumFoil = A2; (if your positive tin foil patch isn't connected to A2, replace that with its proper connected pin)

In the void setup section, include:
Serial.begin(9600); // initialize the serial port
pinMode(aluminumFoil, INPUT); //sets aluminum foil pin to INPUT
digitalWrite(aluminumFoil, HIGH); //initializes the sensor

In the void loop section, your code will need:
sensorValue = analogRead(aluminumFoil); // read the value from the sensor
Serial.println(sensorValue); // send that value to the computer

See full code for more information. Once your code is up to par, click on serial monitor. You'll see a series of numbers. Touch your patches and see how the numbers change. Find the high and low of your range and then determine what ranges you want to include in your code. For example, in my code, it explains that "if (sensorValue < 985 && sensorValue >= 900)", the lights will last 8/10 of a second. If the sensor value reads between 800 and 900, the lights last 5/10 of a second... and so on. Decide what ranges you want to effect the code and how.

______

My entire code:

int aluminumFoil = A2; //this is the pin that the positive tin foil patch is connected to (the other tin foil patch is connected directly to negative)
int sensorValue; // variable to store the value coming from the sensor
int top1 = 2; // top1 is the nickname for the star connected to pin 2
int top2= 3;
int top3 = 9;
int top4= 10;
int rtop1 = A4;
int rtop2= 11;

void setup() // run once, when the sketch starts
{
Serial.begin(9600); // initialize the serial port
pinMode(aluminumFoil, INPUT); //sets aluminum foil pin to INPUT
digitalWrite(aluminumFoil, HIGH); //initializes the sensor
  pinMode(top1, OUTPUT); //if the light isn't turned to output, it will not work 
  pinMode(top2, OUTPUT);
  pinMode(top3, OUTPUT);
  pinMode(top4, OUTPUT);
  pinMode(rtop1, OUTPUT);
  pinMode(rtop2, OUTPUT);

}

void loop() // run over and over again
{
sensorValue = analogRead(aluminumFoil); // read the value from the sensor
Serial.println(sensorValue); // send that value to the computer
if (sensorValue < 985 && sensorValue >= 900) //if the value from the sensors is between 900-985 when touched, the following light pattern will occur:


{
  digitalWrite(top1, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(800); //this indicates how long the light will stay on in milliseconds
  digitalWrite(top1, LOW); //turn the LED off
  digitalWrite(top4, HIGH);
  delay(800);
  digitalWrite(top4, LOW);
  digitalWrite(rtop2, HIGH);
  delay(800);
  digitalWrite(rtop2, LOW);
  digitalWrite(top2, HIGH);
  delay(800);
  digitalWrite(top2, LOW);
  digitalWrite(top3, HIGH);
  delay(800);
  digitalWrite(top3, LOW);
  digitalWrite(rtop1, HIGH);
  delay(800);
  digitalWrite(rtop1, LOW);


  // wait for a second
}


else if (sensorValue < 900 && sensorValue > 800)


{
  digitalWrite(top1, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(500);
  digitalWrite(top1, LOW);
  digitalWrite(top4, HIGH);
  delay(500);
  digitalWrite(top4, LOW);
  digitalWrite(rtop2, HIGH);
  delay(500);
  digitalWrite(rtop2, LOW);
  digitalWrite(top2, HIGH);
  delay(500);
  digitalWrite(top2, LOW);
  digitalWrite(top3, HIGH);
  delay(500);
  digitalWrite(top3, LOW);
  digitalWrite(rtop1, HIGH);
  delay(500);
  digitalWrite(rtop1, LOW);

}


else if (sensorValue < 800 && sensorValue >= 600)
{

  digitalWrite(top1, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(200);
  digitalWrite(top1, LOW);
  digitalWrite(top4, HIGH);
  delay(200);
  digitalWrite(top4, LOW);
  digitalWrite(rtop2, HIGH);
  delay(200);
  digitalWrite(rtop2, LOW);
  digitalWrite(top2, HIGH);
  delay(200);
  digitalWrite(top2, LOW);
  digitalWrite(top3, HIGH);
  delay(200);
  digitalWrite(top3, LOW);
  digitalWrite(rtop1, HIGH);
  delay(200);
  digitalWrite(rtop1, LOW);

}
else //the following code is what will occur if the sensor detects a value different from the ones specified above
{
  digitalWrite(top1, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(1000);
  digitalWrite(top1, LOW);
  digitalWrite(top4, HIGH);
  delay(1000);
  digitalWrite(top4, LOW);
  digitalWrite(rtop2, HIGH);
  delay(1000);
  digitalWrite(rtop2, LOW);
  digitalWrite(top2, HIGH);
  delay(1000);
  digitalWrite(top2, LOW);
  digitalWrite(top3, HIGH);
  delay(1000);
  digitalWrite(top3, LOW);
  digitalWrite(rtop1, HIGH);
  delay(1000);
  digitalWrite(rtop1, LOW);
}
}

Step 6: Sew and Stuff Your Stars (+ Cosmetic Touches)

Once all the technical things work, you can start to sew your stars. I decided to stuff mine so that the LED would light up all the stuffing, but you could choose to leave them unstuffed. If you choose to do without the stuffing, the light will show up as a single dot. The stuffing helps amplify the light. 

***Tip: The edges of my stars started to fray, so I wish I'd done something to prevent that. It made sewing the stars to the blanket more difficult. Fleece or felt would likely not have this problem. 

***Tip: Because I don’t like the look of the exposed tin foil, I decided to “hide” my patches with fabric stars. I sewed a small chunk of the two stars onto the blanket, but let enough un-sewn so that the stars could be lifted up (like little doors) and the patches could be touched. I sewed on velcro bits (which was both difficult and painful, by the way) so that the openable portion of the stars would stay flush to the blanket when not in use. I also decided to alter my code so that when the blanket is turned on, the lights blink (as opposed to being off, as I had it before). This way, the tin foil patches aren’t being used excessively just because the user wants some lights on. The patches will therefore only be used when the user wants the lights to change speed. I figure the lifespan of my patches will last longer this way.

***Tip: To hide my lilypad, I made a moon and left the middle unsewn so that I would still be able to get the USB and battery in without much trouble. Also, the battery tucks right into one side of the moon. See picture below. However, I will that I wish I did something with velcro instead, because despite the large opening, it was hard to see my Lilypad and find the on/off switch. 

Step 7: Finished!

And voila! You've got yourself a fun twinkling blanket. Let me know if you have any questions. This is my first Instructables write-up, so I'm sure I left a few things out.