Raspberry Pi LESSON 31: Making a Dimable LED with Python

In this lesson we are ready to bring together a lot of what we learned in earlier lessons. We will create dimable LEDs which will respond to two buttons. If one is pressed the LED will gradually grow dimmer. If the other is pressed, the LED will gradually grow brighter. This will require us to use our skills in using GPIO inputs, pullup resistors, GPIO outputs, and PWM.

For convenience we will use the same circuit we used in LESSON 30, shown below. Also, if you want to follow along with these lessons, you can buy the gear you need HERE.

This Circuit Controls two LED from Push Buttons Using the Raspberry Pi

The objective of this circuit is that we want the LEDs to grow brighter each time the right button is pushed, and we want them to grow dimmer each time to left button is pushed.

The video above steps through and explains this code.