Raspberry Pi Pico -- TM1637 – 4 Digit, 7 Segment Multiplexed Display Interface

by PugazhM in Circuits > Raspberry Pi

7367 Views, 4 Favorites, 0 Comments

Raspberry Pi Pico -- TM1637 – 4 Digit, 7 Segment Multiplexed Display Interface

Circuit_V01.jpeg

This intractable is about interfacing TM1637-- 4 digits, multiplexed 7 segment display drivers with Raspberry Pi Pico, and it can be programmed using Python, for BCD counting.

Visit the "VESZLE - The Art Of Electronics" you tube channel for further information and videos.
https://www.youtube.com/channel/UCY4mekPLfeFinbQHp...

The TM1367 video link


Abstract

The Raspberry Pi Pico is a tiny, fast, and versatile board built using RP2040 features a dual-core Arm Cortex-M0+ processor with 264KB internal RAM and support for up to 16MB of off-chip Flash. It provides wide range of flexible I/O options includes I2C, SPI, and uniquely Programmable I/O (GPIO) pins.

In Embedded system design, seven segment displays are playing a major role as numerical visual indications. Seven segment LED displays are brighter, more attractive and provide a far viewing distance as well as a wider viewing angle as compared to LCD displays. Its available in wide dimensions (0.3 inch to 6 inch) and different colors (RED, GREEN, BLUE, ORANGE, WHITE). It can display digits from 0 to 9 and quite a few characters like A, b, C, d, E, e, F, n, o, P, t, u, etc.

TM1637 device is a LED driver controller with key scan interface. TM1637 provides 2 digital IO pins (CLOCK and DIO) for interfacing it with external micro controller. The device supports to connect 16 Keys, 6 digits of 7 Segment displays OR 48 individually controllable LEDs. The device supports 8 brightness control levels for LEDs / 7 Segment display.

This intractable is about interfacing TM1637-- 4 digits, multiplexed 7 segment display drivers with Raspberry Pi Pico, and it can be programmed using Python, for BCD counting.

Reference

“Raspberry Pi Pico, Getting Started on Board Blink LED” Instruct-able / You-tube by PugazhM https://www.instructables.com/Raspberry-Pi-Pico-G...


Components

Component.jpg

Raspberry Pi Pico

Micro USB Cable

TM1637 4 Digits, 7 Segment Display Module = 1 No

Schematic

Circuit_V01.jpeg

TM1637 is a LED drive control device, with inbuilt key scan functionality.

It supports two wire serial interface and provides two DIO pins (CLK and DIO), for connecting it into uC.

The TM1637, display mode supports to interface 6 digits of 7 segment displays. Otherwise, it can support 48 individual LEDs.

TM1637 contains inbuilt key scan functionality and supports to connect 16 individual keys.

The device provides inbuilt RC oscillator for generating its clock, and it contains built in power on reset circuit.

TM1637 provides 6 data registers for controlling the 48 LEDs or segments.

It provides auto incremented mode or individual data write mode for accessing data registers. TM

1637 devices supports to control the brightness (8 levels) of the display.

Python Program – TM1637 -- 4 Digit, 7 Segment Multiplexed Display

TaskEvent_V01.jpeg

Download MicroPython TM1637 library. “tm1307.py” driver library from “https://github.com/mcauser/micropython-tm1637/tm1637.py”.

Open the RPi Pico as drive, and then copy the library into root directory.

The timer_one is initialized and callbacks the “BlinkLED” functionality for toggling on board LED at 200mS duration. (frequency = 5)

The timer_two is initialized and callbacks the “UpdateTime” functionality for toggling on board LED and time / clock at 1000mS duration. (frequency = 1)

Program demonstrates scrolling test display

Program demonstrate "4 Digit Up Count" at the interval of 100mS. Starting with 9950. Resets after it reaches 10000. And counts up to 50

Program demonstrate "4 Digit Down Count" at the interval of 100mS. Resets to 9999 after it reaches less than 0.

Program demonstrates displaying three-digit negative number

Program demonstrates displaying two-digit temperature (99 °C)

Program Demonstrate displaying time / clock.


'''<br> Demonstrates the use of TM1637,4 digits of 7 Segment display.
 
 * Demonstrate Scrolling text Display
 * Demonstrate "4 Digit Up Count" at the interval of 100mS.
 * Demonstrate "4 Digit Down count" at the interval of 100mS.
 * Demonstrate displaying negative number.
 * Demonstrate displaying temperature.
 * Demonstrate displaying time / clock.
 The Raspberry Pi Pico circuit connection for TM1637:
 * TM1637 VCC pin to VBUS
 * TM1637 GND pin to GND
 * TM1637 DIO pin to GPIO17
 * TM1637 CLK pin to GPIO16
 
 Name:- M.Pugazhendi
 Date:-  06thAug2021
 Version:- V0.1
 e-mail:- muthuswamy.pugazhendi@gmail.com
'''
import tm1637
from machine import Pin, Timer
from utime import sleep
display = tm1637.TM1637(clk=Pin(16), dio=Pin(17))
#Initialize the onboard LED as ouput
led = Pin(25, Pin.OUT)
#Initialize timer_one. Used for toggeling the LED
timer_one = Timer()
#Initialize timer_two. Used for updating the time
timer_two = Timer()
mm = 15
ss = 45
change  = 0
# Blink LED
def BlinkLED(timer_one):
    led.toggle()
    
# Update Time
def UpdateTime(timer_two):
    global mm
    global ss
    global change
    if change == 1:
        change = 0
        ss = ss + 1
        if ss == 60:
           ss = 0
           mm = mm + 1
        if mm == 60:
           mm = 0
        display.numbers(mm,ss,1)
    else:
        change = 1
        display.numbers(mm,ss,0)
#Initialize count variable with 9950 as initial value
count=9950
# Welcome screen. Scrolling Display.
# Show scrolling text
display.scroll("RPi Pico - TM1637 Display", delay=200)
sleep(2)
# Hi counter
display.show("    ")
display.show("Hi")
sleep(1)
# Execute the Up count loop for 100 times with 0.1 seconds interval
for i in range(101): 
 # Write the count into display buffer
 display.number(count)
 # Increment the count
 count = count + 1
 
 # Validate the count value. If exceeds 10000, reset it it zero.
 if count == 10000:
     count = 0
 # Sleep for about 100mS.   
 sleep(0.1)
 
sleep(1)
# Low Counter
display.show("    ")
display.show("LOW")
sleep(1)
# Execute the Down count loop for 100 times with 0.1 seconds interval
for i in range(101): 
 # Write the count into display buffer
 display.number(count)
 # Decrement the count
 count = count - 1
 
 # Validate the count value. It its negative value, reset it it 9999.
 if count == -1:
     count = 9999
 # Sleep for about 100mS.   
 sleep(0.1)
# Demonstrate 3 digit negative number
sleep(2)
# Displaying negative number
display.show("    ")
display.show("NEG")
sleep(2)
#show negative numbers
display.number(-123)
sleep(2)
# Demonstrate 2 digit temperature. Suffix C
display.show("    ")
display.show("Temp")
sleep(2)
#show temperature
display.temperature(99)
sleep(2)
# Demonstrate Time / Clock. Minutes and Seconds are updated.
# 500mS interval toggles the center LEDs.
display.show("    ")
display.show("Time")
sleep(2)
# Initialize the timer one for first time
timer_one.init(freq=10, mode=Timer.PERIODIC, callback=BlinkLED)
# Update time / clock.
timer_two.init(freq=1, mode=Timer.PERIODIC, callback=UpdateTime)


Conclusion

ConclusionUpcount.jpg

The project is successfully completed with Raspberry Pi Pico and TM1637display driver module.

The TM1637 display driver can be used for many embedded projects as numerical display.

Video Link

ConclusionNegativeNumber.jpg
ConclusionTemperature.jpg
ConclusionTime.jpg

Result_Video.mp4

Visit "VESZLE - The Art Of Electronics" you tube channel for further information and videos. https://www.youtube.com/channel/UCY4mekPLfeFinbQH...

If you enjoyed this instruct-able, then make sure you subscribe

The TM1367 video link