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.

Interrupts
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.