In this video lesson we present the solution to the homework assignment given in LESSON #6. Your assignment was to create a dimmable LED where the brightness of the RGB LED is controlled by the potentiometer. We are still using the schematic from our earlier project.

In this lesson, this is the code which we came up with:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #!/usr/bin/env python3 from fusion_hat.adc import ADC from fusion_hat.pwm import PWM from time import sleep import math potPin=0 myPot = ADC(0) redPin=5 redLED=PWM(redPin) while True: potVal = myPot.read() # 0 to 4095 writeVal=100**(potVal/4095)-.005 redLED.pulse_width_percent(int(writeVal)) print(potVal,writeVal) sleep(0.1) |