Home Hardware A Raspberry Pi Pico GPIO expansion Board

A Raspberry Pi Pico GPIO expansion Board

by rp2040guy71

In this article we look at an expansion board for the Raspberry Pi Pico which is designed to test all of the GPIO pins.

You can see this pictured below, the board contains 5 push buttons, 1 potentiometer and 20 leds connected to various GPIO pins

 

Here is an image of the pins that this board uses

This board has a couple of possible use cases

  • As a demo board , test whether the GPIO pins of Pico are working
  • As an expansion board, this module includes LED, button, ADC basic function.

Purchase

The board only costs about $2

Aliexpress store link

Code

There are a couple of code examples that I could find

This is the button test example, press a button and an LED will light

from machine import Pin
import time
 
led = Pin(15, Pin.OUT)
button = Pin(12, Pin.IN, Pin.PULL_UP)
button1 = Pin(13, Pin.IN, Pin.PULL_UP)
button2 = Pin(14, Pin.IN, Pin.PULL_UP)
button3 = Pin(16, Pin.IN, Pin.PULL_UP)
button4 = Pin(17, Pin.IN, Pin.PULL_UP)
 
while True:
    if button.value() & button1.value() & button2.value() & button3.value() & button4.value() :                       
	    led.low()
	    time.sleep(0.5)
    elif button.value() | button1.value() | button2.value() | button3.value() | button4.value() :
        led.high()
        time.sleep(0.5)

This is an led test example, the LEDs will flash in sequence

from machine import Pin
import time
 
led=[28,27,1,0,22,21,3,2,20,19,5,4,15,18,7,6,11,10,9,8];
 
Pin(led[0], Pin.OUT)
Pin(led[1], Pin.OUT)
Pin(led[2], Pin.OUT)
Pin(led[3], Pin.OUT)
Pin(led[4], Pin.OUT)
Pin(led[5], Pin.OUT)
Pin(led[6], Pin.OUT)
Pin(led[7], Pin.OUT)
Pin(led[8], Pin.OUT)
Pin(led[9], Pin.OUT)
Pin(led[10], Pin.OUT)
Pin(led[11], Pin.OUT)
Pin(led[12], Pin.OUT)
Pin(led[13], Pin.OUT)
Pin(led[14], Pin.OUT)
Pin(led[15], Pin.OUT)
Pin(led[16], Pin.OUT)
Pin(led[17], Pin.OUT)
Pin(led[18], Pin.OUT)
Pin(led[19], Pin.OUT)
 
 
while 1:
    for i in range(len(led)):
        j=Pin(led[i], Pin.OUT)
        Pin(led[0], Pin.OUT).low()
        Pin(led[1], Pin.OUT).low()
        Pin(led[2], Pin.OUT).low()
        Pin(led[3], Pin.OUT).low()
        Pin(led[4], Pin.OUT).low()
        Pin(led[5], Pin.OUT).low()
        Pin(led[6], Pin.OUT).low()
        Pin(led[7], Pin.OUT).low()
        Pin(led[8], Pin.OUT).low()
        Pin(led[9], Pin.OUT).low()
        Pin(led[10], Pin.OUT).low()
        Pin(led[11], Pin.OUT).low()
        Pin(led[12], Pin.OUT).low()
        Pin(led[13], Pin.OUT).low()
        Pin(led[14], Pin.OUT).low()
        Pin(led[15], Pin.OUT).low()
        Pin(led[16], Pin.OUT).low()
        Pin(led[17], Pin.OUT).low()
        Pin(led[18], Pin.OUT).low()
        Pin(led[19], Pin.OUT).low()
 
 
        time.sleep(0.1)
        j.high()
        time.sleep(0.1)

Link

github repo

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More