LAB-5- LED Blinking and Brightness Control
Aim:
To write python code for LED blinking and brightness control using PWM in Raspberry
Pi and test it
Task:
1. Write a Python Program to generate LED Blinking and Brightness Control using PWM in
Raspberry Pi and test it.
Pin and Ciruit Diagaram :
Algorithm:
Mock GPIO functions using MagicMock to simulate the [Link] library.
Setup PWM by initializing it on the LED pin.
Gradually increase the PWM duty cycle to simulate increasing brightness.
Gradually decrease the PWM duty cycle to simulate decreasing brightness.
Simulate LED blinking by toggling the PWM duty cycle between 100% and 0%.
Programs:
Output:
Changing duty cycle to 95%
Changing duty cycle to 90%
Changing duty cycle to 85%
Changing duty cycle to 80%
Changing duty cycle to 75%
Changing duty cycle to 70%
Changing duty cycle to 65%
Changing duty cycle to 60%
Changing duty cycle to 55%
Changing duty cycle to 50%
Changing duty cycle to 45%
Changing duty cycle to 40%
Changing duty cycle to 35%
Changing duty cycle to 30%
Changing duty cycle to 25%
Changing duty cycle to 20%
Changing duty cycle to 15%
Changing duty cycle to 10%
Changing duty cycle to 5%
Changing duty cycle to 0%
Pre Lab Questions:
1. How can power control be done using PWM?
2. Write the function related to PWM generation in Raspberry Pi
Post Lab Questions:
1. What is the impact of the change of frequency PWM on the blinking effect of the LED?
2. Write python code in which LED only make blinking with medium and highest
brightness
Result: