Now we will add the LED into the code, only we'll be doing this differently to what we've done in previous chapters. The purpose of the LED for this exercise is to visually see the effects of changing the duty cycle and frequency characteristics of PWM. We will use the analog inputs of the two Pots to define the PWM duty cycle and frequency.
The code we discuss in this section extends the analog code example we just covered in chapter05/analog_input_ads1115.py to use PiGPIO to create a hardware PWM signal.
Two additional source code files are provided with this book that implement hardware-timed PWM using PiGPIO and software PWM using RPi.GPIO:
- chapter05/pwm_hardware_timed.py
- chapter05/pwm_software.py
Their overall code is similar, with the differences being the methods and input parameters used to invoke PWM. We will revisit these files again in the upcoming section, Visualizing software and hardware-timed PWM.
The code...