In this tutorial we will be using the Raspberry Pi Pico along with the PiStop module from PiMoroni. In this tutorial we will wire up the PiStop module from PiMoroni, connect it up the Raspberry Pi Pico and program it in Micropython so that the Red, Amber, Green LED’s light up in a sequence every few seconds.
PiStop by PiMoroni : The PiStop module from PiMoroni is a simple traffic light module consisting of three LED’S i.e. Green, Amber, Red along with resistors on board to allow you directly interface with any maker board. In our case we chose to use PiStop from PiMoroni along with the Raspberry Pi Pico. The PiStop includes resistors in line with each of the LED’s along with a separate Vcc (power) and GND (ground) line, thus making it really easy for anyone to get started with their traffic light project. The entire package makes it very easy to work with the LED’s and allows embedding the PiStop into various maker projects where a visual traffic light setup might be required.
You can purchase the PiStop from PiMoroni from the following link – PiStop at PiMoroni
Raspberry Pi Pico – Raspberry Pi Pico is a tiny, fast, and versatile board built using RP2040, the flagship microcontroller chip designed by Raspberry Pi in the UK. From light displays and IoT devices to signage and manufacturing processes, Raspberry Pi Pico gives the maker the power to control countless home, hobby, and industrial projects. Programmable in C and MicroPython, the Pi Pico is adaptable to a vast range of applications and skill levels, and getting started is as easy as dragging and dropping a file. More experienced users can take advantage of Raspberry Pi Pico’s rich peripheral set, including SPI, I2C, and eight Programmable I/O (PIO) state machines for custom peripheral support.
Here’s the specifications (from Raspberry Pi Foundation website) of the Raspberry Pi Pico in case you are interested –
- 21 mm × 51 mm form factor
- RP2040 microcontroller chip designed by Raspberry Pi in the UK
- Dual-core Arm Cortex-M0+ processor, flexible clock running up to 133 MHz
- 264kB on-chip SRAM
- 2MB on-board QSPI flash
- 2.4GHz 802.11n wireless LAN (Raspberry Pi Pico W and WH only)
- 26 multifunction GPIO pins, including 3 analogue inputs
- 2 × UART, 2 × SPI controllers, 2 × I2C controllers, 16 × PWM channels
- 1 × USB 1.1 controller and PHY, with host and device support
- 8 × Programmable I/O (PIO) state machines for custom peripheral support
- Supported input power 1.8–5.5V DC
- Operating temperature -20°C to +85°C (Raspberry Pi Pico and Pico H); -20°C to +70°C (Raspberry Pi Pico W and Pico WH)
- Castellated module allows soldering direct to carrier boards (Raspberry Pi Pico and Pico W only)
- Drag-and-drop programming using mass storage over USB
- Low-power sleep and dormant modes
- Accurate on-chip clock
- Temperature sensor
- Accelerated integer and floating-point libraries on-chip
Pinout diagram for the Raspberry Pi Pico – To help you work out which pins are located where and what they are called you can refer to the pinout diagram for the Raspberry Pi Pico provided below.
Circuit Diagram –
The above diagram was put together in Fritzing, not being able to access a PiStop module within Fritzing we have displayed the PiStop as three LED’s with attached resistors in line with each LED. The connections for the PiStop module are to be made as follows –
- Red LED connected to GPIO 18
- Amber LED connected to GPIO 17
- Green LED connected to GPIO 16
- Vcc connected to Vcc or 3V3 OUT
- GND (Ground) connected to GND
If you are using the PiStop PiMoroni module you do not have to use the resistors we’ve shown above. These PiStop module includes SMD resistors on the module. Also ignore the button, we’ll deal with the button in a following tutorial.
Here’s the code for the tutorial that you’ll need to put together. You are encourage to not just copy the code, but rather ask yourself the meaning of each of the lines of code as you type them out and use Google where you need additional support.
from machine import Pin #importing relevant modules & classes
# Setting up each of the pins which we'll use to blink the onboard LED:
led_green = Pin(16, Pin.OUT)
led_amber = Pin(17, Pin.OUT)
led_red = Pin(18, Pin.OUT)
# Blinking the Green LED
# Blinking the Amber LED
# Blinking the Red LED
# Sleeping for 3s
Summary – We hope you’ve enjoyed this tutorial on the PiStop PiMoroni module and the Raspberry Pi Pico. In this module we learned how to setup the PiStop module, connect each of the pins on the PiStop module to the Raspberry Pi Pico and program it in Micropython to get it working. Please drop us a note at trevor at hack2 dot live if you have any questions.