Night Lamp
Night Lamp
What I wanted to learn, and why it interested me: Knowing how to install the hardware and control the LED strip by programing it. LED could efficiently create visual effect and useful in both life and artwork.
Final outcome: A night Lamp. could adjust lighting base on brightness.
Images of final creative/exploratory output
Final video of night Lamp
Final image of night Lamp
Process images from development towards creative/exploratory output
Video: Testing the connection between photoresistor and LED
Testing the connection between photoresistor and LED
Process and reflection:
A very useful little project. It gave me the opportunity to learn about the LED light strips that I had been curious about for a long time. I gained more understanding in the aspects of soldering LEDs and signal flow.
Besides, I fund that when the input is very sensitive, the changes in the LEDs may not be easily observable within a small space.
Technical details
Electrical Schematic above and Block Diagram below
#include <PololuLedStrip.h>
const int LEDSTRIPPIN = 2; // LED strip data pin
const int NUMLEDS = 13; // number of LEDs in the strip
const int LDRPIN = A0; // Photoresistor data pin A0
PololuLedStrip<LEDSTRIPPIN> ledStrip;
rgb_color colors[NUMLEDS];
const int THRESHOLD = 800; // Brightness of environment
void setup(){
pinMode(LDRPIN, INPUT);
Serial.begin(9600); //
}
"void loop(){
int sensorValue = analogRead(LDRPIN); // 0 ~ 1023
if(sensorValue > THRESHOLD){
// Light is bright, turn off the LED
for(int i = 0; i < NUMLEDS; i++){
colors[i] = rgb_color(0, 0, 0);
}
} else {
// lightness go lower, the light getting darker
// 将 [0 ~ THRESHOLD] 映射到 [255 ~ 0]
int brightness = map(sensorValue, 0, THRESHOLD, 255, 0);
// 限制范围,避免异常
brightness = constrain(brightness, 0, 255);
rgb_color yellow = rgb_color(brightness, brightness, 0);
for(int i = 0; i < NUMLEDS; i++){
colors[i] = yellow;
}
}" CITATION HERE, Rewrite by CHATGPT
ledStrip.write(colors, NUMLEDS);
delay(30);
}