Tag Archives: pio

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.

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

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.

 

Control Raspberry Pi Pico PIO State Machines in a Micropython Class

In this video lesson we show how you can control a PIO State Machine on the Raspberry Pi Pico W inside of a micropython class. We demonstrate with the practical example of controlling servos with a servo Class which we create. The objective is to ‘hide’ all the complex code in the class, allowing less adept users to interact with the servo with simple python commands. For your convenience the code developed in this video is included below. Enjoy!

 

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!

 

Sweeping Servo Position Using the PIO State Machine on the Raspberry Pi Pico PIO State Machine

 

In this video lesson we show how you can use the Raspberry Pi Pico PIO State Machine to sweep a servo through its full range of motion. The video will take you through things step-by-step. For your convenience the code developed in the video is included below. Enjoy!