Go Down

Topic: Heart Mood Light (Read 1 time) previous topic - next topic

abbijo

This is my heart mood light, i have two LED lights a blue and red one. They fad from on and off at different times to switch up the colors and make purple at once. I used the Arduino to create this and just a simple plastic heart.

Video of the heart in action - http://www.youtube.com/watch?v=0ehsETNgHxw

code:

Code: [Select]
int rPin = 5;
int bPin = 3;
int rVal = 0;

void setup(){
  pinMode(rPin, OUTPUT);
pinMode(bPin, OUTPUT);
Serial.begin(9600);

}

void loop(){
  // Fade on
for(int i=0; i<255; i++){
   analogWrite(rPin, i);
   analogWrite(bPin, abs(255-i));
   delay(10);
   Serial.println(i);
}

//Fade off
for(int i=0; i<255; i++){
   analogWrite(rPin,abs(255-i) );
   analogWrite(bPin,i);
   delay(10);
   Serial.println(i);
}
/*
  if(cnt < 255){
     analogWrite(rPin, cnt);
     analogWrite(bPin, abs(255-cnt));
     cnt = cnt+1;
     delay(10);
     Serial.println(cnt);
  } else if (cnt > 0){
     analogWrite(rPin, abs(255-cnt));
     analogWrite(bPin, cnt);
     cnt = cnt-1;
     delay(10);
  }
  */
}

mattnupen

looks great!  how did you get the hear to "glow" light that?  what did you use to diffuse the light within the plastic heart or did you buy it like that?

thanks

Go Up