nithishmurugavenkateshmaker
Published

Light-Activated RBG lamp

Would it be cool to have a lamp that switches on automatically when the lights turn off? Well, here it is!

IntermediateFull instructions provided122
Light-Activated RBG lamp

Things used in this project

Hardware components

Photo resistor
Photo resistor
×1
Arduino UNO
Arduino UNO
×1
9V battery (generic)
9V battery (generic)
(OPTIONAL IF YOU DON"T NEED POWER SOURCE)
×1
9V Battery Clip
9V Battery Clip
(OPTIONAL IF YOU DON"T NEED POWER SOURCE)
×1
RBG led
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

The Code

C/C++
const int R = A0;
const int G = A1; 
const int B = A2;
int RValue;
int GValue;
int BValue;
const int sensorPin = 2;
int readsensor;

void setup() {
pinMode(R, OUTPUT);
pinMode(G, OUTPUT);
pinMode(B, OUTPUT);
pinMode(sensorPin, INPUT); 
  

}

void color(int RValue, int GValue, int BValue){
  analogWrite(R, RValue);
  analogWrite(G, GValue);
  analogWrite(B, BValue);
  
}


void loop() {
  readsensor = digitalRead(sensorPin);
  if(readsensor == HIGH){
    color(255,0,0);
    delay(100);
    color(0, 0, 255);
    delay(100);
    color(0, 255, 0);
    delay(100);
  }
  else{
    color(0,0,0);
  }
   
}

Credits

nithishmurugavenkateshmaker
4 projects • 2 followers

Comments