You are on page 1of 2

Ex: No:7 Raspberry Pi based auto intensity controlling of

Date: solar LED street lights

Aim:
To control the intensity of LED lights based on solar light using Raspberry Pi.
Apparatus Required:
S.No Name of the Component Description Quantity
1. Raspbery Pi Model 3 or Model 4 1
2. Keyboard - 1
3. Mouse - 1
4. Monitor - 1
5. LDR 3mm 1
5. Resistor 10K, 330ohms 1 each
6. LED 3mm 1
7. Bread Board - 1
8. Connecting Wires - few

Circuit Diagram and Connection Diagram:

Program:
from gpiozero import PWMLED, MCP3008 # import necessary packages
from time import sleep

ldr = MCP3008(0) #create an object ldr which refers to MCP3008 channel 0


led = PWMLED(17) #create a PWMLED object called led that refers to GPIO 17
while True:
if(ldr.value < 0.001): #the ldr.value accesses the current LDR reading
led.value = 1 #if the ldr value is very small, the led is turned ON ie dark
else:

led.value =1 - ldr.value
#change led brightness accordingly to the ldr value
print(ldr.value) #print the ldr value
sleep(1) #pause for 1 seconds

Output:

Result:
Thus the intensity of LEDs is controlled by sensing the solar light and implemented
successfully..

You might also like