Practical 2 Displaying Time over 4-Digit 7-Segment Display Using Raspberry Pi
Practical 2 Displaying Time over 4-Digit 7-Segment Display Using Raspberry Pi
Hardware Required:
1. Raspberry Pi 3B+
2. Ethernet Cable
3. Monitor
4. HDMI to VGI converter (required only in case of VGA cable)
5. adapter with 5V/2A
6. USB mouse
7. USB keyboard
8. 16X2 LCD display
Procedure:
1. Hardware Setup:
VCC + 5V Power 4 5V
CLK Clock 16 23
DI0 Data In 18 24
In order to control the LED, using a special script with pre-defined functions.
Various functions are available in the script, for example, to display numbers
and adjust the intensity of the LEDs.
$ wget https://raspberrytips.nl/files/tm1637.py
Note:
1. This Script file contains some of the important functions, which are required to
add in our Python script.
2. Save the at the file same location (/home/pi/4digitTime )
import sys
import time
import datetime
import RPi.GPIO as GPIO
import tm1637
#CLK -> GPIO23 (Pin 16)
#Di0 -> GPIO24 (Pin 18)
Display = tm1637.TM1637(23,24,tm1637.BRIGHT_TYPICAL)
Display.Clear()
Display.SetBrightnes(1)
while(True):
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.