Display Time Over 4 Digit 7 Segment Display
Display Time Over 4 Digit 7 Segment Display
Installation Manual
To display small amount of data with Raspberry Pi, we can use 4 digit 7-segment Display.
7 Segment Display has seven segments in it and each segment has one LED inside it to display
the numbers by lighting up the corresponding segments.
Hardware Requirements
1. Raspberry Pi Model A/B/B+
2. 4 digit 7 Segment Display
3. Jumper wires (Female to Female)
Software Requirements
1. Raspbian Stretch OS
1. Connect your 4 digit 7 segment display with Raspberry Pi's GPIO Pins.
TM1637 Board
Function RPI Physical Pin Raspberry Function
Pin
GND Ground 14 GND
VCC + 5V Power 4 5V
Note: This Script file contains some of the important functions, which are required to add in our
Python script.
import sys
import time
import datetime
import RPi.GPIO as GPIO
import tm1637
Display.Clear()
Display.SetBrightnes(1)
while(True):
now = datetime.datetime.now()
hour = now.hour
minute = now.minute
second = now.second
currenttime = [ int(hour / 10), hour % 10, int(minute / 10), minute % 10 ]
Display.Show(currenttime)
Display.ShowDoublepoint(second % 2)
time.sleep(1)
The above script needs the tm1637.py script to work, so place both files in the same folder.
Script functions
The clock script uses the following functions, defined in tm1637.py:
Display. Clear () - Clears the display if individual LEDs are still active.
Display.SetBrightnes(x) - After this you can adjust the brightness of the display, at least 0 and
maximum 7.
Display. Show(x,x,x,x) - Show the actual 4 digits (digits), x can be 0 to 9.
Display.ShowDoublepoint (status) - Controlling the ':' between the second and third digit, true
(1) = on / false (0) = off.