Wednesday, 22 February 2023

Exercise 1 using TM1637

#Library import utime import tm1637 from machine import Pin #setup tm = tm1637.TM1637(clk=machine.Pin(4), dio=machine.Pin(5)) #to clear the display tm.show(' ') utime.sleep(2) #to present data on the display #here are the examples tm.number(1) utime.sleep(2) tm.number(12) utime.sleep(2) tm.number(123) utime.sleep(2) tm.number(1234) utime.sleep(2) #notice that the display starts from right to left tm.show("AbCd") utime.sleep(2) #Show scrolling text #delay controls the speed of the scrolling text. #The default delay is set as 250ms tm.scroll("8888 8888 8888", delay=300) utime.sleep(2) #to display time with the colon seperating hour and minutes tm.numbers(12,30) utime.sleep(2) #Temperature #Display with the degree Celsius sign #it accepts 2 digit +ve no. or a single digit with -ve no. tm.temperature(37) utime.sleep(2) #digital clock while True: time=utime.localtime() print(time) #(2023, 2, 6, 20, 14, 57, 0, 37) # 0 1 2 3 4 5 6 7 hr=time[3] mn=time[4] tm.numbers(hr,mn) utime.sleep(15) tm.show(' ') #if you open up tm1637.py you can see the functions number() and numbers() #in this library #From SSGoh on Github #Also From: https://microcontrollerslab.com/7-segment-display-raspberry-pi-pico/

No comments: