Category Archives: Python

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.

 

Raspberry Pi LESSON 61: Finding and Tracking Faces and Eyes In OpenCV

In this video lesson we show how to use Haar Cascades in OpenCV on the Raspberry Pi to find and track  faces and eyes. We show the intelligent way to find eyes, such that CPU resources are not wasted. Below we show the code for your convenience.

 

Raspberry Pi LESSON 59: Improved Pan/Tilt Tracking Control Algorithm


 

In this Video Lesson we show an improved control algorithm for tracking an Object of Interest in OpenCV. We develop a simple example of Proportional control, where the correction signal is proportional to the error signal. We show this is a much improved algorithm over our earlier one, which simply applied 1 degree corrections independent of the size of the error. The code we develop in this lesson is included below for your convenience.

 

Raspberry Pi LESSON 38: Motion Detection Alarm with Multiple Alarms

In this video lesson we show how to create an Alarm System based on a Raspberry Pi, with user input from a keypad, and user prompts on an I2C LCD Display. From the earlier lessons in this series, you must install the LCD1602 Library, and you must install the keypad library. We include the code that we develop in this lesson below for your convenience:

 

Library for Reading a 16 Button Keypad on the Raspberry Pi

In this lesson we show you how to create a Python Class and Library that allows you to easily get user input on a Raspberry Pi from a 16 button keypad. This will allow very easy interaction with the keypad.

The Library Code which we develop in the video is presented below for your convenience:

To use this code as a library, save it in the same folder as your python programs, and save it as KPLIB.py

 

This is a simple demo program that calls the library above, to receive input from the keypad.