Multi-function lamp

LED

Made by Mo Zhang

This prototype shows a lamp with 3 phases. We know that different light has different effects on people. This lamp provide people suitable light according to different activity. Phase one is working light -- a blueish light that helps with concentration. Phase two is a yellowish light that suit for relaxing daily life. Phase three is party time, when the light will change according to the music.

Created: January 29th, 2015

0

This prototype shows a lamp with 3 phases. We know that different light has different effects on people. This lamp provide people suitable light according to different activity. Phase one is working light -- a blueish light that helps with concentration. Phase two is a yellowish light that suit for relaxing daily life. Phase three is party time, when the light will change according to the music.

0
0
// Define a pin that we'll place the FSR on
// Remember to add a 10K Ohm pull-down resistor too.
int fsrPin = A1;
int Pin=A2;

// Create a variable to hold the FSR reading
int fsrReading = 0;

// Define a pin we'll place an LED on
int g = D0;
int r = A0;
int b = D1;
// Create a variable to store the LED brightness.
int ledBrightness = 0;
int val=0;
int val1=0;
int state = 0;

int old_fsrReading = 0;

void setup()
{
  // Set up the LED for output
  pinMode(g, OUTPUT);
  pinMode(r, OUTPUT);
  pinMode(b,OUTPUT);
//  analogWrite(ledPin,255);

analogWrite(g,255);
analogWrite(r,255);
analogWrite(b,255);
}

void loop()
{
  // Use analogRead to read the photo cell reading
  // This gives us a value from 0 to 4095
  fsrReading = analogRead(fsrPin);
  val=analogRead(Pin);

  // Map this value into the PWM range (0-255)
  val=map(val,0,4095,0,255);
  val=80*(255-val);
  val1=val/10;
//  val=map(val,255,0,100,0);
//  ledBrightness = map(fsrReading, 0, 4095, 0, 255);
//  ledBrightness = 255-ledBrightness;
if ((fsrReading>50) && (old_fsrReading==0)){
  state = state+1;
  delay(50);

}

state=state % 4;
  // fade the LED to the desired brightness


if (state==1){
  analogWrite(g,0);
  analogWrite(r,255);
  analogWrite(b,0);
} else if(state==2){
  analogWrite(g,200);
  analogWrite(r,0);
  analogWrite(b,255);
} else if(state==3){
  analogWrite(g,val);
  analogWrite(r,255);
  analogWrite(b,255);
} else if(state==0){
  analogWrite(g,255);
  analogWrite(r,255);
  analogWrite(b,255);
}
  // wait 1/10th of a second and then loop
  delay(100);
}
Click to Expand
x
Share this Project


About

This prototype shows a lamp with 3 phases. We know that different light has different effects on people. This lamp provide people suitable light according to different activity. Phase one is working light -- a blueish light that helps with concentration. Phase two is a yellowish light that suit for relaxing daily life. Phase three is party time, when the light will change according to the music.