Line: 1 to 1 | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||
Changed: | |||||||||||||
< < | 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:![]() Exercise 2:This is the most simple program in embedded systems. So... nothing much to say! https://iotworkshop.africa/pub/IoT_Course_English/SolutionsToNopLEDsAndNopNeoPixel/blink.py.txt | |||||||||||||
Added: | |||||||||||||
> > | 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://iotworkshop.africa/pub/IoT_Course_English/SolutionsToNopLEDsAndNopNeoPixel/sos.py.txtExercise 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://iotworkshop.africa/pub/IoT_Course_English/SolutionsToNopLEDsAndNopNeoPixel/pwmExerciseSol.py.txt : the linear cycle and https://iotworkshop.africa/pub/IoT_Course_English/SolutionsToNopLEDsAndNopNeoPixel/pwmLED.py.txt : the sinusoidal cycleExercise 5:Switching on the LEDs one by one we see that
Exercise 6 and 7:Once we know the LED addresses it is easy to switch them on clockwise and anticlockwise https://iotworkshop.africa/pub/IoT_Course_English/SolutionsToNopLEDsAndNopNeoPixel/ws2812Colors.py.txt https://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. | ||||||||||||
-- ![]() Comments
| |||||||||||||
Changed: | |||||||||||||
< < |
| ||||||||||||
> > |
|