SolutionsToNopLEDsAndNopNeoPixel

Page Actions

Solutions to Exercise 2: LEDs

Exercise 1:

Here is the screen dump of a REPL session switching the builtin LED on and off:

builtinLED.png

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

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.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://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 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://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://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.

-- %USERSIG{UliRaich - 2020-05-06}%

Comments

 
I Attachment Action Size Date Who Comment
blink.py.txttxt blink.py.txt manage 617 bytes 06 May 2020 - 10:00 UnknownUser  
builtinLED.pngpng builtinLED.png manage 17 K 06 May 2020 - 09:47 UnknownUser  
pwmExerciseSol.py.txttxt pwmExerciseSol.py.txt manage 1 K 30 May 2020 - 15:05 UnknownUser  
pwmLED.py.txttxt pwmLED.py.txt manage 1 K 30 May 2020 - 15:05 UnknownUser  
sos.py.txttxt sos.py.txt manage 897 bytes 30 May 2020 - 15:05 UnknownUser  
ws2812Addresses.py.txttxt ws2812Addresses.py.txt manage 1 K 30 May 2020 - 15:05 UnknownUser  
ws2812Colors.py.txttxt ws2812Colors.py.txt manage 1 K 30 May 2020 - 15:05 UnknownUser  
ws2812ColorsCCW.py.txttxt ws2812ColorsCCW.py.txt manage 1 K 30 May 2020 - 15:05 UnknownUser  
Topic revision: r2 - 30 May 2020, UliRaich