Adaptive LED Lighting Based on Ambient Light & Motion

Hi everyone,

I’m working on a small Arduino project to control LED lighting based on ambient light levels and motion detection.

Goal

Create a system where:

LEDs gradually turn on when the room gets dark

LEDs brighten only when someone is in the room

LEDs fade off after no motion is detected for a set time

Hardware

Arduino Uno (or Nano)

LDR (photoresistor) or BH1750 light sensor

PIR motion sensor

WS2812 or simple RGB LEDs + resistors

Optional: potentiometer to adjust sensitivity

Current Setup

I have the sensors connected and reading values, but I’m stuck on:

Smoothing the ambient light readings (so lights don’t flicker)

Combining motion + light threshold logic

What I’d Like Help With

Example code snippet to read the light sensor and debounce flicker

Tips on managing power/LED brightness smoothly (PWM or library suggestions)

Best way to structure the logic (ambient threshold vs motion trigger)

Any suggestions or example sketches would be appreciated!

Thanks

For Neopixel, you can use the Adafruit_NeoPixel or FastLED library. Smooth fades using built-in color blending or manual interpolation.

This looks like a school assignment.

What is the deadline for submitting the project?

This results in the room never getting dark.

This will immediately go to the first state of LEDs ON.

Show the code you are stuck on, and a drawing of the wiring.

The BH1750 has 50/60Hz rejection filters so smoothing is not necessary.

OP has a habit of posting then disappearing.