Chapter 4 – Analog & PWM released (smooth breathing + flowing light bar)

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

4 Likes

Could you also make a tutorial on I2C? I recently tried it out with a friend but we got stuck. We were quite unsure if we should have used mem_write or master_transmit. Even after hocking it up to an oscilloscope we couldn’t really make sense of the output :sweat_smile:

1 Like

I’ll just go down this Tutorial for C for there Raspberry Pi Pico here:

I don’t know yet what’s all in it.

Martin

1 Like