Devices & Components
Arduino UNO EK (एक) R4 Minima Robu
LM393 Photosensitive Light-Dependent Control Sensor LDR Module
Jumper Wire Robu.in
Mini Breadboard Robu.in
WS2812B 5V Addressable RGB Non-Waterproof LED Strip Light Robu
Software & Tools
Arduino IDE
Project description
Code
Need the Arduino Code?
cpp
Here’s the ready-to-upload IR-based RGB light code
1#include <Adafruit_NeoPixel.h> 2#define LED_PIN 6 3#define NUM_LEDS 16 4#define LDR_PIN A0 5 6Adafruit_NeoPixel strip(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800); 7int currentPattern = 0; 8const int totalPatterns = 10; 9bool isDark = false; 10unsigned long lastChange = 0; 11 12void setup() { 13 strip.begin(); 14 strip.show(); 15 Serial.begin(9600); 16} 17 18void loop() { 19 int lightValue = analogRead(LDR_PIN); 20 if (lightValue < 300) { 21 if (!isDark) { 22 isDark = true; 23 Serial.println("🌑 It's dark – RGB ON"); 24 } 25 if (millis() - lastChange > 5000) { 26 currentPattern = (currentPattern + 1) % totalPatterns; 27 lastChange = millis(); 28 } 29 runPattern(currentPattern); 30 } else { 31 if (isDark) { 32 isDark = false; 33 Serial.println("☀️ Bright – RGB OFF"); 34 strip.clear(); 35 strip.show(); 36 } 37 } 38 delay(100); 39}
Downloadable files
schematics for Smart Ambient RGB Light – Powered by LDR & Arduino UNO EK (एक) R4 Minima
Arduino-uno-ek-minima-1.jpg

Comments
Only logged in users can leave comments