Hello everyone,
I have just published Chapter 4 of the Pi Ada Tutorial:
Analog & PWM – Building smooth breathing LEDs and a flowing light bar
In this chapter we create a reusable Pico.Analog package that provides clean Write_Analog procedures for both Percentage and Analog_Level, plus convenient Map functions.
Highlights:
- Fixed-point arithmetic done right (multiply first, then divide)
- Real oscilloscope measurements with the Voltcraft MSO-5102B showing before/after behaviour
- A subtle PWM slice calculation bug in the experimental RP2350 HAL that only appeared on the Pico 2
- The bug is now fixed and a pull request has been submitted
The chapter contains two main examples:
- sketch_04_1_breathing_light.adb (single smooth LED)
- sketch_04_2_flowing_light_2.adb (10-LED comet / flowing bar)
All code is available in the tagged release v1.3.3 of pico_xbsp and pico_ada_c04_pwm.
Full chapter with videos and oscilloscope screenshots:
As always, feedback and suggestions are very welcome!
Happy hacking,
Martin
