Introduction of the Project
If you’re looking for a fun and easy DIY project that can make your neighborhood a little brighter, look no further than building your own automatic streetlight with Arduino! With just a few simple components and some programming know-how, you can create a device that senses when the sun goes down and automatically turns on a light to keep your street or driveway illuminated. In this Arduino project, we will use a photoresistor sensor, which will help us to glow the bulb at night time and automatically turn it off when daylight is present.
To get started, you’ll need an Arduino board, a photoresistor, a resistor, a breadboard, and some wires. You’ll also need a light fixture that you can connect to the relay module. Once you have your components, it’s time to start building.
First, connect the photoresistor l to the breadboard and use wires to connect it to the Arduino board. Next, connect the relay module to the breadboard and use wires to connect it to the Arduino board as well. Finally, connect your light fixture to the relay module.
Now it’s time to write the code. You’ll need to use the Arduino IDE to create a program that reads the values from the photoresistor and determines whether it’s dark enough to turn on the light. When the light needs to be turned on, the program will activate the relay module to switch the light on.
Once your code is written, upload it to your Arduino board and watch as your automatic streetlight comes to life! With just a few simple steps, you’ll have a device that makes your home a little safer and more secure. Plus, it’s a fun and educational way to learn more about programming and electronics. So why not give it a try today?
Supplies
In order to make an Automatic Streetlight with Arduino, we will require the following components listed below:
Components
- Arduino Uno R3
- 1 Bulb
- 1 Photoresistor Sensor
- 1 Small Breadboard
- 1 Resistor
- Connecting Wires
Circuit Diagram
Steps To Make An Automatic Streetlight With Arduino
Step 1: First, we gathered all the components on the Digital Board.
Bulb:
Step 2: Connect the +ve terminal of the bulb to the GND(ground) pin of the Arduino.
Step 3: Connect the -ve terminal of the bulb to the Number-5 pin of the Arduino.
PhotoResistor Sensor:
Step 4: Connect the 1st terminal of the Photoresistor to the 5V pin of the Arduino.
Step 5: Connect the 2nd terminal of the Photoresistor to the GND pin of the Arduino through a resistor.
Step 6: Connect the same second terminal of the Photoresistor to the A0 number pin of the Arduino.
Source Code
int bulb = 5; int sensor = A0; void setup() { pinMode(5, OUTPUT); pinMode(A0, INPUT); } void loop() { int sensorValue; digitalWrite(bulb, LOW); sensorValue = analogRead(sensor); if(sensorValue <= 400) digitalWrite(bulb, HIGH); }
Explanation of the Code
1. In the beginning, we initialized two variables, bulb, and sensor, namely to which the respective component is connected to their respective Arduino pin number.
2. In the setup function, we have configured the Arduino pins for input and output purposes.
3. In the loop function, we have declared a variable “sensorValue” to store the value of the photoresistor sensor, after which we are reading the value from the sensor.
4. If the “sensorValue” is less than or equal to 400 means it’s night time, and hence, we are glowing the bulb. During the day, it will not glow as the intensity of daylight is already high.
Output
We will get the following output on the successful completion of the project.
On starting the simulation, the Bulb will glow if the intensity of the daylight is low(i.e., at night time), else it will not glow.

Cisco Ramon is an American software engineer who has experience in several popular and commercially successful programming languages and development tools. He has been writing content since last 5 years. He is a Senior Manager at Rude Labs Pvt. Ltd.
0 Comments