Introduction: Motion Sensing Beaded Curtain

This is a project we created as part of our Computing and Crafts final project. The assignment was to “produce a family of devices for a given cause”. We chose to create this beaded door curtain and a window curtain (featured in a different Instructable) to address the need for self expression in dorm rooms.

This curtain is fairly simple to create, and lights up when someone walks by/through it.

Materials:
• Store bought beaded curtain (we used this curtain: http://www.save-on-crafts.com/crystalcurtain.html )
• 6 feet of multi-stranded fiber optic rope (we used http://www.wiedamark.com/42strandsideglow.aspx )
• 11 or more RGB LEDS
• 1 motion sensor (we used http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=255-1816-ND )
• Lots of wire (black, red, blue, and green if possible)
• On/Off switch
• Batteries and battery pack (we used 3 AAA)
• Arduino uno
• 2-3 index cards or some light-weight cardstock
• Rapid prototyping machine/scrap plastic/foam core
• Solder/soldering iron
• Masking tape
• Hot glue gun
• Heat shrink tubing and heat gun
• String to tie wires down

Step 1: Make the Basic Circuit


Following the circuit diagram above, wire one RGB LED and the motion sensor to the Arduino (note: check the datasheet for your particular motion sensor before wiring). Run the code below and confirm that the LED  runs through all three colors in unison when the motion sensor detects movement.

You can adjust the code to change the color of the LED and make whatever pattern you like. Ours had two LEDs (simply hook it up to three unused PWM pins) and was set to alternate through cool colors (one set of LEDs faded between blue and red, the other set between green and blue).


(How the code works: Basically, the code is a modified version of Sparkfun's code for using a photoresistor to control LEDs. If the motion sensor "sees" something, the voltage in A0 spikes. When the code detects this spike, it runs the LEDs through their colors and if there is no spike the LEDs stay off.)



CODE:

int lightPin = 0; //actually the motion sensor

// LED leads connected to PWM pins
const int RED_LED_PIN = 9;
const int GREEN_LED_PIN = 10;
const int BLUE_LED_PIN = 11;

// Used to store the current intensity level of the individual LEDs
int redIntensity = 0;
int greenIntensity = 0;
int blueIntensity = 0;

// Length of time we spend showing each color
const int DISPLAY_TIME = 50; // In milliseconds
void setup()
{
// pinMode(ledPin1, OUTPUT); //sets the led pin to output
// pinMode(ledPin2, OUTPUT); //sets the led pin to output
// pinMode(ledPin3, OUTPUT); //sets the led pin to output
Serial.begin(9600);
}

void loop()
{
int lightLevel = analogRead(lightPin); //Read the motion sensor

Serial.println(lightLevel);
if (lightLevel < 650) { //if the sensor sees motion (voltage spikes above threshold)
// Cycle color from red through to green
// (In this loop we move from 100% red, 0% green to 0% red, 100% green)
for (greenIntensity = 0; greenIntensity <= 255; greenIntensity+=5) {
redIntensity = 255-greenIntensity;
analogWrite(GREEN_LED_PIN, greenIntensity);
analogWrite(RED_LED_PIN, redIntensity);
delay(DISPLAY_TIME);
}

// Cycle color from green through to blue
// (In this loop we move from 100% green, 0% blue to 0% green, 100% blue)
for (blueIntensity = 0; blueIntensity <= 255; blueIntensity+=5) {
greenIntensity = 255-blueIntensity;
analogWrite(BLUE_LED_PIN, blueIntensity);
analogWrite(GREEN_LED_PIN, greenIntensity);
delay(DISPLAY_TIME);
}

// Cycle cycle from blue through to red
// (In this loop we move from 100% blue, 0% red to 0% blue, 100% red)
for (redIntensity = 0; redIntensity <= 255; redIntensity+=5) {
blueIntensity = 255-redIntensity;
analogWrite(RED_LED_PIN, redIntensity);
analogWrite(BLUE_LED_PIN, blueIntensity);
delay(DISPLAY_TIME);
}
}

else{ //if the sensor doesn't see anything
analogWrite(RED_LED_PIN, 0);
analogWrite(BLUE_LED_PIN,0);
analogWrite(GREEN_LED_PIN,0);
//digitalWrite(ledPin1,LOW);
//digitalWrite(ledPin2, LOW);
//digitalWrite(ledPin3, LOW);
}
}


Step 2: Wire the LEDs

The curtain contains two separate strings of LEDs, each of which is simply soldered in series (see diagram). To start a string, take an LED and bend the ground lead ninety degrees from the other leads. Clip the lead to be about one centimeter long and solder on a black wire. Slip a piece of heat shrink tubing over the connection and heat with the heat gun. Repeat with the green lead, bending it in the same direction as the ground lead and soldering on a green wire (see picture). Continue with the blue and red leads, eventually ending up with the leads spread out flat (see picture).

To wire the rest of the string, follow the same process but cut the old wire and add a new one, so you are soldering together three parts (it helps to twist the two wires together before soldering them onto the LED lead). Determine the length of the wire from the curtain you are using and the spacing of your LEDs. It is better to have a little extra wire, but too much makes it difficult to fit inside the curtain. Also, make sure to put the heat shrink over the wires before you solder them to the lead.

You can check the finished LED strings with the code below by simply plugging them in place of the individual LEDs.

CODE:

int lightPin = 0; //motion sensor pin
// LED leads connected to PWM pins
const int RED_LED1_PIN = 9;
const int GREEN_LED1_PIN = 10;
const int BLUE_LED1_PIN = 11;

const int RED_LED2_PIN = 5;
const int GREEN_LED2_PIN = 6;
const int BLUE_LED2_PIN = 3;


// Used to store the current intensity level of the individual LEDs
int redIntensity1 = 0;
int greenIntensity1 = 0;
int blueIntensity1 = 0;

// Length of time we spend showing each color
const int DISPLAY_TIME = 50; // In milliseconds
void setup()
{
Serial.begin(9600);
}

void loop()
{
int lightLevel = analogRead(lightPin); //reads the motion sensor
Serial.println(lightLevel);
if (lightLevel < 350) { // 350 w/battery, 480 w/USB Cycle color from green through to blue
// (In this loop we move from 100% green, 0% blue to 0% green, 100% blue)
for (blueIntensity1 = 0; blueIntensity1 <= 225; blueIntensity1+=5) {
greenIntensity1 = (255-blueIntensity1)-25;
// blueIntensity2 = blueIntensity2;
// greenIntensity2 = 255-blueIntensity2;
analogWrite(BLUE_LED1_PIN, blueIntensity1);
analogWrite(GREEN_LED1_PIN, greenIntensity1);
analogWrite(RED_LED2_PIN, blueIntensity1);
analogWrite(BLUE_LED2_PIN, greenIntensity1);
delay(DISPLAY_TIME);
}

// Cycle cycle from blue through to red
// (In this loop we move from 100% blue, 0% red to 0% blue, 100% red)
for (redIntensity1 = 0; redIntensity1 <= 225; redIntensity1+=5) {
blueIntensity1 = (255-redIntensity1)-25;
// redIntensity2 = redIntensity1;
// blueIntensity2 = 255-redIntensity2;
analogWrite(GREEN_LED1_PIN, redIntensity1);
analogWrite(BLUE_LED1_PIN, blueIntensity1);
analogWrite(BLUE_LED2_PIN, redIntensity1);
analogWrite(RED_LED2_PIN, blueIntensity1);
delay(DISPLAY_TIME);
}

}


else {
analogWrite(RED_LED1_PIN, 0);
analogWrite(BLUE_LED1_PIN,0);
analogWrite(GREEN_LED1_PIN,0);
analogWrite(RED_LED2_PIN, 0);
analogWrite(BLUE_LED2_PIN,0);
analogWrite(GREEN_LED2_PIN,0);
}
}


Step 3: Attach Fiber Optics to LEDs

In order for the fiber optics to light up as much as possible, the light from the LEDs needs to be focused. To do this, create small cones out of the index cards that fit around both the LED and a small bundle (3-4 fibers) of fiber optics. Use hot glue to connect the cone to the LED and the fibers (be careful not to melt the fibers). Repeat this for all of the LEDs.

Step 4: Put Wiring in Curtain

Use hot glue to attach the LEDs (via the paper cones) to the inside of the curtain. The curtain we used had a tray holding the beads that slid out and made attaching the LEDs easy. If your curtain doesn’t have this, make a new curtain top using a PVC pipe or sheets of plastic. Glue the LEDs according to the pattern given earlier, being careful not to pull out the fiber optics.

Add wires for the motion sensor, placing them to stick out of the middle of the curtain, where the motion sensor will be located. Tie down all of the wires with string, compressing them as much as possible so they will fit inside the curtain (We tied them down with string). Carefully slide the tray back into the curtain casing. The wires for connecting the motion sensor and LEDs to the Arduino should be sticking out of the side of the casing.

Check the LEDs by plugging the wires into the Arduino to ensure that nothing broke within the casing.


Step 5: Attach the Motion Sensor

We created a custom box with a rapid prototyping machine (aka. 3D printer) for our motion sensor (see .pdf for dimensions) , but you can create something similar with scrap plastic or some foam core. Basically, you need to create a case to hold the sensor without impeding its sensing range.
After the case is fabricated, solder the ends of the wires to the motion sensor and fit it all into the case. The case (with the wires hidden inside) can be glued to the rest of the curtain.



Step 6: Wire and Attach the Parts

Next, make a box to hold all the electronics (Arduino and batteries) out of foamcore. Make sure to cut two holes in the side; one for all the wires going into the box and one for the on/off switch. CHECK THAT EVERYTHING FITS IN THE BOX. Then use hot glue to attach the box to the curtain and the on/off switch (with the wires already attached) to the box.

Simply put the Arduino and batteries into the box (we added a bit of tape so they wouldn't slide around) and plug in all the wires. The wires from the battery pack go into Vin and GND.

Optional: Write up a circuit/wiring guide and tape inside the box lid to make it easier to fix if necessary.

Step 7: Done!

Finally, close the box and you're ready to go!