Introduction: How Can We Make a Dimable LED Using Raspberry Pi
In this project I'm going to tell you about how we can control the brightness of two leds using two push buttons with raspberry pi.
Step 1: Software Required
a) Raspbian OS: This is the recommended os for raspberry pi. You can also installed other OS from third party. Raspbian OS is debian based OS. We can install it from noobs installer. you can Download it from here
b) Python idle: This is the software we get in raspbian os. For this project we have used python script.
c) Putty: We are using putty for remote access of Raspberry Pi.you can Download it from here
d) Win32DiskImager: This software is used to burn Raspbian Os on SD Card. you can Download it from here
e) SDFormatter: This software is used to format memory card. you can Download it from here
Step 2: Components Used
For this project you need :
1) Raspberry pi 3 :
This is the latest version of raspberry pi. In this we have inbuilt Bluetooth and wi-fi, unlike previously we have to use Wi-Fi dongle in one of its usb port. There are total 40 pins in RPI3. Of the 40 pins, 26 are GPIO pins and the others are power or ground pins (plus two ID EEPROM pins.)
There are 4 USB Port and 1 Ethernet slot, one HDMI port, 1 audio output port and 1 micro usb port and also many other things you can see the diagram on right side. And also we have one micro sd card slot wherein we have to installed the recommended Operating system on micro sd card.
There are two ways to interact with your raspberry pi. Either you can interact directly through HDMI port by connecting HDMI to VGA cable, and keyboard and mouse or else you can interact from any system through SSH(Secure Shell). (For example in windows you can interact from putty ssh.) Figure is given above.
2) Two LEDs
3) Two Push Buttons
Step 3: Project Discription
In this project basically we will go through about 4 things. And those are GPIO Inputs, pullup resistor, GPIO outputs and PWM. So whenever we will press one button the intensity of leds will increase, and if we will press another button the intensity of leds will decrease. Two buttons will work as GPIO Inputs and two leds will work as GPIO outputs. Here we are using PWM concepts. As we need to give pulses to leds pins and we will start PWM at 0 percent duty cycle and will go to 100 percent duty cycle.
Step 4: Circuit Diagram
Here we are using the GPIO pin number scheme so as you can see in the circuit two buttons are connected to GPIO pins of 23 and 18 respectively, and two leds are connected to GPIO pins of 25 and 24 respectively.
Step 5: Source Code and How to Run the Code in Your Raspberry Pi
You can get the source code of this project down below. Click on the link and download it. Now how to run this code.
For that first login to your raspberry pi by SSH or if you are using dedicated monitor for that so just power up your raspberry pi, now create one directory in your desktop named dimable by giving the command
sudo mkdir dimable
now go to that directory, give command
now make one file by giving the command
sudo nano dimable.py
Now in this file just paste the downloaded code and now the final step is just run that code by giving the command
sudo python dimable.py
Step 6: Project Video and Conclusion
So after successfully running the last command you can enjoy this Dimable leds project.
The whole project description are given in the above video
If you have any doubt regarding this project feel free to comment us below or you can mail us on firstname.lastname@example.org And if you want to learn more about these type of project then feel free to visit our youtube channel
Thanks & Regards,