Recent Changes - Search:

Main
Intro to PComp Home
Weekly Topics & Assignments
Wednesday Class Dates

Links:

Final Projects


Midterm Projects

PmWiki

edit SideBar

GroupLuminous

Luminous

Concept

A dress that changes color. We are using fiber optics and tri-color LEDs to modulate the color of the dress according to input from a thermistor.











Code that we used:
int thermistor; int i=0; int rangedValue=0;

int redpin=9; int greenpin=10; int bluepin=11;

int redP=3; int greenP=6; int blueP=5;

int thermistorswitch=7; int spectrumswitch=12; int onswitch=13;

int redVal=255; int greenVal=0; int blueVal=0;

int redVal2=255; int greenVal2=0; int blueVal2=0;

void setup(){

  pinMode(redpin,OUTPUT);
  pinMode( bluepin,OUTPUT);
  pinMode(greenpin,OUTPUT);
  pinMode(thermistorswitch,INPUT);
  pinMode(spectrumswitch,INPUT);
  pinMode(spectrumswitch,OUTPUT);
  thermistor=analogRead(3);
  Serial.begin(9600);

}

void loop(){

  if (digitalRead(spectrumswitch)==HIGH){

    i += 1;      // Increment counter

    if (i < 256) // First phase of fades
    {
      greenVal += 1; // Green up, resulting color: yellow
    }
    else if (i < 511) // Second phase of fades
    {
      redVal -= 1; // Red down, resulitng color: green

    }
    else if (i < 766) // Third phase of fades
    {
      blueVal += 1; // Blue up, resulitng color: cyan
    }
    else if (i<1021)
    {
      greenVal -=1; //Green down, resulting color: blue
    }
    else if (i<1276)
    {
      redVal +=1; //red up, resulting color: magenta
    }
    else if (i<1531)
    {
      greenVal +=1;
    }
    else if (i<1785)
    {
      blueVal -=1;
      greenVal -=1;
    }
    else // Re-set the counter, and start the fades again
    {
      i = 0;
      redVal = 255;
      blueVal = 0;
      greenVal = 0;
    }
    analogWrite(redP,redVal);
    analogWrite(blueP,blueVal);
    analogWrite(greenP,greenVal);
  }


  if(digitalRead(thermistorswitch)==HIGH){

    thermistor=analogRead(3);
    redVal2 = intRanger(85,107,100,255,thermistor);
    blueVal2=255-redVal2;
    analogWrite(redP,redVal2);
    analogWrite(blueP,blueVal2);
    analogWrite(greenP,greenVal2);

  }
  if(digitalRead(thermistorswitch)==LOW){
    redVal2=120;
    blueVal2=0;
    greenVal2=120;
  }
  if (digitalRead(onswitch)==HIGH){
    analogWrite(redP,redVal);
    analogWrite(blueP,blueVal);
    analogWrite(greenP,greenVal);
  }

} int intRanger( int originalMin, int originalMax, int newMin, int newMax, int currentValue) {

  long zeroRefOriginalMax =0;
  long zeroRefNewMax = 0; 
  long zeroRefCurVal = 0;
  int rangedValue = 0;

  // Check for out of range currentValues
  if (currentValue < originalMin) {
    currentValue = originalMin;
  }
  if (currentValue > originalMax) {
    currentValue = originalMax;
  }


  // Zero Refference the values
  zeroRefOriginalMax = originalMax - originalMin;
  zeroRefNewMax = newMax - newMin;
  zeroRefCurVal = currentValue - originalMin;

  // Check for negative values and 0 max ranges
  if ( (zeroRefNewMax < 1) || (zeroRefOriginalMax < 1) || (originalMin < 0) || (originalMax < 1) || (newMin < 0) || (newMax < 1) || (currentValue < 0)  ) {
    return 0;
  }

  rangedValue =  ( (zeroRefCurVal * zeroRefNewMax) / zeroRefOriginalMax ) + newMin ;

  return rangedValue;

}





Here is the basic setup before we moved it to a smaller board and took out the color sensor.





Click here for a video of the tri-color LEDs cycling through all ot the colors.

We had to scrape the sides of the fiber optics to get the light to bleed through.


The ends of the fiber optics have to be looking straight to LEDs so that they get as much light as possible. We were looking at secure ways to connect the leds to fiber optics. Here we used heat shrink.


On our first attempt to connect the LEDs to wire, we used short wires to connect the LEDs to each other in parallel. We also ended up just using electrical tape to connect the fibers to the LEDs, which worked pretty well, once the tape was wrapped around tightly enough.


Kyveli wore the dress to the final show.(It was lit though you can't really tell here.)

Edit - History - Print - Recent Changes - Search
Page last modified on April 06, 2007, at 03:41 PM