Introduction: Simple Night Lamp
Here is a very fast and simple night light which is not disturbing you at night until you sleep. Also it`s economic(using just 5V from the card). It`s very simple and some people will find it useless but it`s for fun.
Step 1: What We Need
1xArduino Uno rev. 3
1xBreadboard
6xDupont wires
1xPhotoresistor
1xLED
1x1kOhm resistor
1x220Ohm resistor
Step 2: Source Code
const int sensorMin = 0;
const int sensorMax = 600;
void setup() {
Serial.begin(9600);
if (!Serial) {};
pinMode(8, OUTPUT);
}
void loop() {
int sensorReading = analogRead(A0);
int range = map(sensorReading, sensorMin, sensorMax, 0, 1);
switch (range) {
case 0:
digitalWrite(8, HIGH);
break;
case 1:
digitalWrite(8, LOW);
break;
}
delay(100);
}
Step 3: Info
The original source code is not mine. I just modified it to work for this case.
With this one the LED will switch on when you switch off the light. At least you will have some light in the room as much as not to break your nose in the wall if you go night time for glass of water.