Smart Upcycled Necklace by Agatha Lee is licensed under a
To give the project a sparkle, I sewed on the LilyPad board, light sensor and LED lights. This project glows when it is dim or dark, and flickers when it is bright. You don't have to do the electronics, but I think I'm hooked ever since doing the blink bike bag! Read below for the tutorial.
PS: If you would like to see this in person, do drop by the Arduino Day on Saturday!
Step 1. I cut out the desired necklace shape on the jeans. I cut out two of these - one for the base (A), and the other for the electronics (B). If you are not going to use electronics, just cut one.
Step 2.
Base (B) was strengthened with felt. Again, if you are not going to use electronics, strengthen Base (A) instead. I used Elmer's Craft Bond, but it wasn't as permanent as it said it would be. In fact, the felt started to peel off by the time I got to sewing on my electronics. So, if you are going to glue the felt on, I would recommend fabric glue instead.
Step 3.
Base (A) was decorated. You won't believe that my husband was the one who suggested adding lace to the jean material. I was so surprised! I hand stitched the lace on the base and then decided on where the crystals and craft gems would go. If you are using electronics in your project:
a) your crystals need to be transparent.
b) go for crystals with lots of cuts so you get different colours and dimensions coming through when the LED lights get going. I was a bit adventurous and bought a few pear-shaped crystals.
c) the location of your LEDs will determine where the crystals will be placed. Just plan ahead with the circuit arrangement before sewing the crystals in!
Step 4.
No electronics? Skip this step and go to step 5!
Cut out small holes directly under the crystals Base (A). If you are using a jean base then it won't unravel!
Place Base (A) over (B) and using tailor chalk, mark out the position of the LEDs on (B). The marks should be directly below the holes on Base (A).
Mark out position of LilyPad board and sew all components with conductive thread.
Test conductivity with multimeter.
Program the LilyPad board
I originally planned to have the sensor on the left but it ended up on the right as I realised the connecting petals were on a different side - my mistake! |
Step 5.
Sew two bases together with the black ribbon in between, and you're done!
Programme - at the moment it looks like one long snake so if anyone knows how to improve this code I will give you a big hug (electronic one, if you're overseas) and a shout out! I wanted to get the glowing to occur randomly but not really sure how to do it. :-)
/* Bib necklace sensing
*/
int ledPin1 = 11; // LED 1
int ledPin2 = 10; // LED 2
int ledPin3 = 9; // LED 3
int ledPin4 = 6; // LED 4
int ledPin5 = 5; // LED 5
int photocellPin = A5; // the cell connected to A5
int photocellReading; // the analog reading from the analog resistor divider
void setup() {
// We'll send debugging information via the Serial monitor
Serial.begin(9600); // initialise serial port
pinMode(ledPin1, OUTPUT); // Set LED 1 to be Output
pinMode(ledPin2, OUTPUT); // Set LED 2 to be Output
pinMode(ledPin3, OUTPUT); // Set LED 3 to be Output
pinMode(ledPin4, OUTPUT); // Set LED 4 to be Output
pinMode(ledPin5, OUTPUT); // Set LED 5 to be Output
digitalWrite(ledPin1, LOW); //sets LED off
digitalWrite(ledPin2, LOW); //sets LED off
digitalWrite(ledPin3, LOW); //sets LED off
digitalWrite(ledPin4, LOW); //sets LED off
digitalWrite(ledPin5, LOW); //sets LED off
}
void loop() {
photocellReading = analogRead(photocellPin);
Serial.print("Analog reading = ");
Serial.print(photocellReading); // the raw analog reading
// Light sensor readings - different levels different response
if (photocellReading < 10) {
Serial.println(" - Dark/Dim - Glow");
ledGlow3();
ledGlow();
ledGlow4();
ledGlow2();
ledGlow3();
ledGlow5();
delay(100);
} else if (photocellReading < 600) {
Serial.println(" - Dim - Flicker");
ledFlicker();
} else if (photocellReading < 800) {
Serial.println(" - Extremely bright");
ledOff();
}
delay(2000);
}
void ledFlicker(){ // LED flicker like mad!
analogWrite(ledPin1, random(28,100));
analogWrite(ledPin2, random(28,100));
analogWrite(ledPin3, random(28,100));
analogWrite(ledPin4, random(28,100));
analogWrite(ledPin5, random(28,100));
delay(random(50,250));
}
void ledGlow(){ // LED glow
// fade in from min to max in increments of 5 points:
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin1, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
// fade out from max to min in increments of 5 points:
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin1, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
}
void ledGlow2(){ // LED glow
// fade in from min to max in increments of 5 points:
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin2, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
// fade out from max to min in increments of 5 points:
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin2, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
}
void ledGlow3(){ // LED glow
// fade in from min to max in increments of 5 points:
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin3, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
// fade out from max to min in increments of 5 points:
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin3, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
}
void ledGlow4(){ // LED glow
// fade in from min to max in increments of 5 points:
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin4, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
// fade out from max to min in increments of 5 points:
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin4, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
}
void ledGlow5(){ // LED glow
// fade in from min to max in increments of 5 points:
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin5, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
// fade out from max to min in increments of 5 points:
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin5, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
}
void ledOff(){ // Turn off LEDs
analogWrite(ledPin1, 0);
analogWrite(ledPin2, 0);
analogWrite(ledPin3, 0);
analogWrite(ledPin4, 0);
analogWrite(ledPin5, 0);
}
Looks great Agy! I'm intrigued by all this electronic wizadry!
ReplyDeleteThanks, Jill. Still a lot to learn.
DeleteLove the necklace!
ReplyDeleteThank you , San.
DeleteYou can use arrays to do some of the repetitive things, like setting everything all of the LED pins to be outputs.
ReplyDeleteFor example, the code might look like this:
/*************************************/
int pin[] = {10,11,A2,A3,A4,A5,6,9}; // array of LilyPad pins
/* in void setup() */
for (int i = 0; i < 8; i++)
{
pinMode(pin[i], INPUT); // declare LilyPad pins as digital inputs
digitalWrite(pin[i], HIGH); // set internal pull-up resistors
}
void loop()
{
for (int i = 0; i < 8; i++) // check all of the pins
{
pinValue = digitalRead(pin[i]); // check if circuit associated with the pin is closed
}
}
/*******************************************/
I'm too lazy to type out how arrays work and the proper syntax. If you want a fuller response, drop me an email/Facebook message and I can send some notes!
Thank you, and thanks for sending me the slides :-)
Delete