Tuesday, November 13, 2018

LED Strip Kitchen Lighting Fade with a PIR Sensor

An Arduino is at the heart of an auto fading LED strip mounted under the kitchen cabinets. When a PIR (Passive InfraRed) sensor detects motion, the Arduino fades the LED strip on via a power FET module. If there is no motion, after x seconds the LEDs fade off again. The brightness can be adjusted via a rotary encoder and the encoder's switch is used to change states between 'off', 'on/off based on sensor trigger', 'permanent on, sensor inactive'.

Check out this video to see it in action plus an explanation how to build it.



The software


The software contains a configuration section at the top where you can change the following parameters and hardware pinning to your preferences:
#define STAY_ON_TIME 20 // [s] fade off after ... seconds
#define SHORT_PRESS_TIME 50 // [ms
#define LONG_PRESS_TIME 1500 // [ms]
#define FADE_INTERVAL 30 // [ms] time between LED fade steps
#define BRIGHTNESS_A 200 // 0-255
#define BRIGHTNESS_B 50 // 0-255
#define ENC_CLK_PIN 2 // rotary encoder CLK or A
#define ENC_DATA_PIN 3 // rotary encoder DATA or B
#define ENC_SW_PIN 4 // rotary encoder SWITCH
#define SENSOR_PIN 6 // HIGH = movement detected
#define PWM_OUTPUT_PIN 5 // only use PWM pins: 3,5,6,9,10,11


(Click the images to see a larger version)

Parts needed and how to connect it:

Click the links below to see where you can buy:

Total cost is around $15,-.

How I mounted the Arduino, PIR sensor, FET module and rotary encoder under my kitchen cabinets:


Brightness can be changed by rotating the encoder. The state the LED lighting is in can be changed by pressing the encoder:

Have fun building and using this.

Rudy.