0% found this document useful (0 votes)
71 views4 pages

Practical 2 Displaying Time over 4-Digit 7-Segment Display Using Raspberry Pi

Uploaded by

Rahul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views4 pages

Practical 2 Displaying Time over 4-Digit 7-Segment Display Using Raspberry Pi

Uploaded by

Rahul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Practical No: 2

Aim: 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

9. 4 Digit 7 Segment Display

Procedure:
1. Hardware Setup:

7 Segment Display Function Pin No Function/GPIO

GND Ground 14 GND

VCC + 5V Power 4 5V

CLK Clock 16 23

DI0 Data In 18 24

2. Software Setup and Program:

Step 1: Download Python Script -

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.

By - Prof. Bhakti Raut


Create a folder 4digitTime under /home/pi.

Download the script using wget command.

$ 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 )

Step 2: Write Python Script to display Time (e.g clock.py)

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):

By - Prof. Bhakti Raut


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.

To know more about TM1637 controller, check


http://www.microcontroller.it/english/Tutorials/Elettronica/componenti/TM1637.htm

Step 3: Start the script with following command

By - Prof. Bhakti Raut


To run the script in the background, you can use the following command:

By - Prof. Bhakti Raut

You might also like