News

moodlite - Coming soon


brightness with day cycle

marky · 200

marky

  • Newbie
  • *
    • Posts: 11
    • Likes: +1/-0
    • View Profile
on: February 25, 2019, 10:44:03 PM
I would like to have in the code something like this

-Light Dependent Resistor (LDR)
-100k Resistor

----Code---
#define LDR_ON                     false      // Flag to use LDR sensor   

if LDR_ON
#define LDR_PIN = D0;

void loop() {
int LDRValue = analogRead(LDR);

if (LDRValue <=700)
{
digitalWrite(LED, 100% brightness);

if (LDRValue <=800)
{
digitalWrite(LED, 90% brightness);

if (LDRValue <=900)
{
digitalWrite(LED, 80% brightness);
.... and so on true the day


else
{
digitalWrite(LED, off);

Serial.println("its day time; Led status: OFF");
}



is that something that would be possible how do you feel about it ?

possible usefull link
https://www.kitronik.co.uk/blog/how-an-ldr-light-dependent-resistor-works/
https://circuitdigest.com/microcontroller-projects/smart-phone-controlled-arduino-mood-based-lights
https://circuitdigest.com/microcontroller-projects/arduino-light-sensor-using-ldr



spigot

  • Global Moderator
  • Full Member
  • *****
    • Posts: 112
    • Likes: +24/-0
  • There's no place like 127.0.0.1
    • View Profile
Reply #1 on: February 27, 2019, 07:30:11 AM
Hi.

    I already did one project with LDR, but for me it isn't very reliable. It shouldn't be hard to implement. I'll look into it.
« Last Edit: February 27, 2019, 07:41:36 AM by spigot »



 


SMF spam blocked by CleanTalk