concept
The idea for this concept comes from a point of laziness, as in my room, when I want to turn the lights off, I need to immediately go to sleep, as I don’t have a nightlight for when I want to sleep.
Therefore, with my little understanding of Arduino hardware and coding, I decided to do a simple enough project but also being functional.
When making the circuit I needed help, and I was looking into many YouTube videos in order to find a way to properly understand it, I took what I could from the videos and made my circuit and code accordingly.
Circuit
Here is the schematic for the circuit:
And here is the project in action:
There weren’t many problems with the circuit working, however, I do wish I could have added more to make it more complex, however that will only come as I get more experienced with Arduino and coding for it.
Code
I was lost as to how to write the code, and found a code in one of the videos I found.
/*
LDR sensor
BY STUPIDCREATIVITY
*/
void setup() {
Serial.begin(9600);
pinMode(13,OUTPUT);
}
void loop() {
float sensorValue = analogRead(A0);
// Reads the analog input ranging from 0 to 1023
Serial.println(sensorValue);
if(sensorValue<=400)
{
digitalWrite(13,HIGH);
}
else
digitalWrite(13,LOW);
}
Now that I am looking back to the project after days of making it, I realize that the code is not as complex as I thought as the beginning. I do comprehend it now, however at the time I made the circuit I did not know.
Further Improvements
I would have preferred for this project to have taken less time, however I am satisfied with what I did. Maybe I’d like to add a kill-switch or a way for the circuit to end after x amount of time.
