Home Hardware 4 digit 8 segment Display Module for the Pico

4 digit 8 segment Display Module for the Pico

by rp2040guy71

In this article we look at a 4 digit 8 segment Display Module for your Raspberry Pi Pico.

The display module is designed to have the Raspberry Pi Pico fitted to it, if you were to do this then you would get access to any of the other unused pins. You can used an expansion board which will allow you to fit the display module but not directly to the Pico.

0.56 inch 4 digit 8 segment Display Module, Compatible with the Raspberry Pi pico size

Pinout

d_pins=[1,13,19,17,16,10,20,18];
w_pins=[21,12,11,0];

raspberry pi pico pinout

raspberry pi pico pinout

Purchase

This LCD costs around $15

Amazon –

Aliexpress –

Code example

This is the Micropython example from the link underneath

from machine import Pin
import time

d_pins=[1,13,19,17,16,10,20,18];
w_pins=[21,12,11,0];
DIG1=Pin(w_pins[3], Pin.OUT)#千位位码
DIG2=Pin(w_pins[2], Pin.OUT)#百位位码
DIG3=Pin(w_pins[1], Pin.OUT)#十位位码
DIG4=Pin(w_pins[0], Pin.OUT)#个位位码
A=Pin(d_pins[0], Pin.OUT)
B=Pin(d_pins[1], Pin.OUT)
C=Pin(d_pins[2], Pin.OUT)
D=Pin(d_pins[3], Pin.OUT)
E=Pin(d_pins[4], Pin.OUT)
F=Pin(d_pins[5], Pin.OUT)
G=Pin(d_pins[6], Pin.OUT)
DP=Pin(d_pins[7], Pin.OUT)
number={
    '0':
    [0,0,0,0,0,0,1,1],#0
    '1':
    [1,0,0,1,1,1,1,1],#1
    '2':
    [0,0,1,0,0,1,0,1],#2
    '3':
    [0,0,0,0,1,1,0,1],#3
    '4':
    [1,0,0,1,1,0,0,1],#4
    '5':
    [0,1,0,0,1,0,0,1],#5
    '6':
    [0,1,0,0,0,0,0,1],#6
    '7':
    [0,0,0,1,1,1,1,1],#7
    '8':
    [0,0,0,0,0,0,0,1],#8
    '9':
    [0,0,0,0,1,0,0,1],#9
}
           
def display(num,DP):
    global number
    count=0
    for i in range (len(d_pins)):
        s=Pin(d_pins[i], Pin.OUT)
        s.value(number[num][count])
        count+=1
    if DP==1:
        Pin(d_pins[7], Pin.OUT).value(0)
        
def clear():
    for i in range (len(w_pins)):
        j=Pin(w_pins[i], Pin.OUT)
        j.value(0)
        time.sleep(0.0001)
    for i in range (len(d_pins)):
        h=Pin(d_pins[i], Pin.OUT)
        h.value(1)
        time.sleep(0.0001)
                    
        
def showData(num):
    d_num=num
    location=d_num.find('.')
    if location>0:
        d_num=d_num.replace('.','')
    while len(d_num)<4:
        d_num='0'+d_num
    for i in range(0,4):
        time.sleep(0.001)
        clear()
        k=Pin(w_pins[3-i],Pin.OUT)
        k.value(1)
        if i==location-1:
            display(d_num[i],1)
       
        else:
            display(d_num[i],0)
        
    if location<0:
        for i in range(0,4):
            time.sleep(0.001)
            clear()
            k=Pin(w_pins[3-i],Pin.OUT)
            k.value(1)
            display(d_num[i],0)

    
    
while True:
    
    def int_str():
        for a in range(0,6):
            for b in range(0,10):
                for c in range(0,6): 
                    for d in range(0,10):
                        for j in range(0,10):
                            #for k in range(0,10):#调整显示速度快慢
                                    
                            dig=a*1000+b*100+c*10+d
                                
                            num=str(dig)
                            showData(num)
    int_str()

 

Links

 

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