|
META TOPICPARENT |
name="Solutions" |
|
|
< < | Solutions to the Exercise of LEDs |
> > | Solutions to Exercise 2: LEDs |
| Exercise 1:
Here is the screen dump of a REPL session switching the builtin LED on and off: |
| This is the most simple program in embedded systems. So... nothing much to say!
https://afnog.iotworkshop.africa/pub/IoT_Course_English/SolutionsToNopLEDsAndNopNeoPixel/blink.py.txt |
|
> > | Exercise 3:
Exercise 3 is not much more difficult neither. We create a function called pulse, which takes a !pulseLength as parameter. This function switches the LED on for pulseLength seconds and off again for another pulseLength seconds. This function is called 3 times with a short !pulseLength, 3 times with a long pulseLength and again 3 times with a short pulseLength.
Here is the code:
https://afnog.iotworkshop.africa/pub/IoT_Course_English/SolutionsToNopLEDsAndNopNeoPixel/sos.py.txt
Exercise 4:
This was an exercise we did during the IoT workshop at the African Internet Summit 2019 in Kampala, Uganda and the solution comes from this workshop.
It defines a function intensityCycle, which increases the PWM duty cycle in steps given by the resolution parameter and keeps this intensity stable for a duration given by the duration parameter. It does so for duty cycle 0 up to duty cycle 1 and then back to duty cyle 0.
At the Kampala workshop we also had a demo program cycling the intensity not in a linear but a sinusoidal fashion. Both programs are given here:
https://afnog.iotworkshop.africa/pub/IoT_Course_English/SolutionsToNopLEDsAndNopNeoPixel/pwmExerciseSol.py.txt : the linear cycle and
https://afnog.iotworkshop.africa/pub/IoT_Course_English/SolutionsToNopLEDsAndNopNeoPixel/pwmLED.py.txt : the sinusoidal cycle
Exercise 5:
Switching on the LEDs one by one we see that
- address 0 corresponds to the middle LED
- address 1 to the top LED
- and the others in clockwise progressing around the circle
https://afnog.iotworkshop.africa/pub/IoT_Course_English/SolutionsToNopLEDsAndNopNeoPixel/ws2812Addresses.py.txt
Exercise 6 and 7:
Once we know the LED addresses it is easy to switch them on clockwise and anticlockwise
https://afnog.iotworkshop.africa/pub/IoT_Course_English/SolutionsToNopLEDsAndNopNeoPixel/ws2812Colors.py.txt
https://afnog.iotworkshop.africa/pub/IoT_Course_English/SolutionsToNopLEDsAndNopNeoPixel/ws2812ColorsCCW.py.txt
Changing the colors is done by passing the corresponding RGB (Red,Green,Blue) values to the WS2812 driver. |
|
-- Uli Raich - 2020-05-06 |
|
META FILEATTACHMENT |
attachment="builtinLED.png" attr="" comment="" date="1588758454" name="builtinLED.png" path="builtinLED.png" size="18252" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="blink.py.txt" attr="" comment="" date="1588759211" name="blink.py.txt" path="blink.py.txt" size="617" user="UliRaich" version="1" |
|
|
< < |
META FILEATTACHMENT |
attachment="sos.py.txt" attr="" comment="" date="1588759211" name="sos.py.txt" path="sos.py.txt" size="897" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="pwmExerciseSol.py.txt" attr="" comment="" date="1588759830" name="pwmExerciseSol.py.txt" path="pwmExerciseSol.py.txt" size="1297" user="UliRaich" version="1" |
|
> > |
META FILEATTACHMENT |
attachment="sos.py.txt" attr="" comment="" date="1590851158" name="sos.py.txt" path="sos.py.txt" size="897" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="pwmExerciseSol.py.txt" attr="" comment="" date="1590851158" name="pwmExerciseSol.py.txt" path="pwmExerciseSol.py.txt" size="1297" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="pwmLED.py.txt" attr="" comment="" date="1590851158" name="pwmLED.py.txt" path="pwmLED.py.txt" size="1075" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="ws2812Addresses.py.txt" attr="" comment="" date="1590851158" name="ws2812Addresses.py.txt" path="ws2812Addresses.py.txt" size="1173" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="ws2812Colors.py.txt" attr="" comment="" date="1590851158" name="ws2812Colors.py.txt" path="ws2812Colors.py.txt" size="1380" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="ws2812ColorsCCW.py.txt" attr="" comment="" date="1590851158" name="ws2812ColorsCCW.py.txt" path="ws2812ColorsCCW.py.txt" size="1519" user="UliRaich" version="1" |
|