JeetRanjan
Published © GPL3+

PhotoMood

This light starts to flash as soon as light level changes.

BeginnerFull instructions provided528
PhotoMood

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Ky-016 3-color led
×1
KY-018 Photo Resistor Module
×1
Jumper wires (generic)
Jumper wires (generic)
if using breadboard then all 7 should be male to male else if you are connecting directly to sensors you will need male to female connectors.
×7

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

Photo Mood

Arduino
You adjust the value of photo resistor value based on your room lightings and set the 3 color led module to flash for any color that makes your mood.
/*

#Code written by TeamUltron
#Satyajeet Ranjan
#02-10-2017
# this project uses a photo resistor module and a 3 color led module
# Feel free to contact me for any help. 'satyajeet.ra2016@gmail.com'
# any suggestion is always welcome.
**NO RIGHTS RESERVED


*/


int sensorPin = A5; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int red = 8;     //red pin for led module
int blue =9 ;    //blue pin for led module
int green = 10;   //green pin for led module
int val = 255;    //taking the max value for lights
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
  pinMode(ledPin, OUTPUT);
  Serial.begin(115200);
}
void loop() {
  sensorValue = analogRead(sensorPin);
  
  if(sensorValue <=290)
  {

    Serial.println("DAY LIGHT");
    analogWrite (red,100);          
    analogWrite (blue, 100);          //Led will be static
    analogWrite (green, 120);
    
    
  }
  else if (sensorValue>=500){
    Serial.println("night light");
    for (val = 255; val> 0; val --)  //using for loop to keep led flashing.
  {
    analogWrite (red, val);
    analogWrite (blue, 255-val);
    analogWrite (green, 255);
    delay(10);
    analogWrite (red, val);
    analogWrite (blue, val-65);
    analogWrite (green, val-40);
    delay(5);
  }
  }
  else{

    Serial.println("Light not that good");
     for (val = 255; val> 0; val --){
       analogWrite (green, val);
       delay(10);
    analogWrite (red, 300-val);}
    analogWrite (blue, 128-val);
    delay(10);
  }
  digitalWrite(ledPin, HIGH);  //blinking arduino led based on the sensor val.
  delay(sensorValue);
  digitalWrite(ledPin, LOW);
  delay(sensorValue);
  Serial.println(sensorValue, DEC);  //print the decimal value from sensor
}

Credits

JeetRanjan
2 projects • 0 followers

Comments