Tag Archives: State Machines

Raspberry Pi Pico PIO State Machine IRQ Interrupts and Handlers

In this video lesson we learn how to use and handle multiple IRQ interrupts using the Raspberry Pi Pico PIO state machines. We demonstrate this by using 3 LEDs, controlled by three separate buttons. We show how to set, clear, and wait on IRQ interrupts. We show how to use blocking and no blocking interrupts. In this video lesson, we use the following circuit.

Circuit Schematic for Button Control LED Interrupts

For your convenience, the code we develop in the video is presented below.

 

Raspberry Pi Pico PIO State Machine IRQ Interrupts

 In the video lesson above, we show how to incorporate IRQ interrupts on the Pi Pico PIO State Machines. The state machines will monitor the buttons, watching for button presses. When a button is pressed, an interrupt is set. That interrupt can then be used by that same state machine, a different state machine on the same PIO, or in the main micropython program. Our first example will be to toggle the LED in the main python program, based on the interrupt from the state machine. In the second example, one state machine monitors the button, and the second state machine controls the LED. This is a schematic for the circuit we will be using.

Circuit Schematic for Button Control LED Interrupts

This first code controls the LED from the main python program.

This next program uses only the state machines. Interrupts and LED control are both done in the state machines.

 

Using Multiple Raspberry Pi Pico PIO State Machines at the Same Time

In this video lesson we show how you can work with more than one state machine at the same time in microPython on the Raspberry Pi Pico W. We show this in the context or controlling multiple servos. We show different ways to utilize multiple state machines. For your convenience, we provide the code developed in the video below. Enjoy!