Uploaded by 97manishapandey

Practical No 3

advertisement
Practical No. 3
TM1637 7 segment display example on a Raspberry Pi
Hardware Guide:
For completing this lesson, you will require the following things along with your initial Raspberry Pi
setup.
a. TM1637 4-digit seven segment display board.
b. Connecting Wires.
TM1637 4-digit seven segment display board:
This is a common anode 4-digit tube display module which uses the TM1637 driver chip. Only 4
connections are required to control the 4-digit 8-segment displays.




Four 7-Segment LED Displays with 0.36″ high red digits
Built-in TM1637 LED Driver
2-wire serial interface for easy hookup to uC
3.3 and 5V compatible
Raspberry Pi GPIO pinout: -
Wiring up your Circuit:
Here is how to hook the module up




Connect the Pin 2(5v) of Rpi to VCC pin of Module.
Connect the Pin 6(GND) of Rpi to GND of Module.
Connect the Pin38 (GPIO 20) of Rpi to DIO pin of Module.
Last connect the Pin40 (GPIO 21) of Rpi to CLK pin of Module.
Problems and solution encountered:

While working with the kit see to it all connections are done properly because sometimes it
would not give the desired output.
 While coding take care of the indentations and save the file name properly in the respective
folder.
Code:
1.import tm1637:
TM1637 4-digit display Module is a 4-pin module for digital display through the combination of four
7-segments. The module is basically for a digital display of alphanumeric data. The basic structure of
the module is the combination of four 7-segments and two LEDs. The LEDs are used as a ratio sign
display. So here we are importing that module to our program by using import keyword.
2. import thread:
Thread module in python provides us classes and methods to create and start threads in
python for implementing multithreading.
3.except ImportError:
ImportError is raised when a module, or member of a module, cannot be imported.
4. Display = tm1637.TM1637:
Calling a constructor from a class TM1637 and passing parameters to it, and storing the value in
variable named display.
5.Display.StartClock:
Calling the method StartClock and passing parameters to it. This method is used for starting
the clock and display it on 4-digit 7 segment display.
6.Display.SetBrightness:
It is method used to set the brightness of the clock when it gets displayed on 4-digit 7 segment
display.
7.Display.ShowDoublepoint:
It is the method which takes one parameter that is of Boolean type. It is used to make sure that the
doublepoint i.e. colon (:) in the clock should be displayed or not.
8.Display.StopClock:
It is the method that is called to stop the clock from getting displayed in the 4-digit 7 segment
display.
9.thread.interrupt_main():
The main thread can be interrupted via the thread.interrupt_main() function. This function can be
called from another thread which will by default raise a signal.SIGINT (interruption signal) that will
be sent to the main thread.
10.KeyboardInterrupt:
KeyboardInterrupt is a Python exception that is thrown when a user or programmer interrupts a
program's usual execution. While executing the program, the Python interpreter checks for any
interrupts on a regular basis.
11.Display.cleanup():
Clean up all the ports/pins you've used. It only affects any ports/pins you have set in the current
program. It resets any ports/pins you have used in this program back to input mode.
OUTPUT:
1. GIVE DETAILED DESCRIPTION OF 4 DIGIT DISPLAY WITH THE PINOUTS.
The Bare 4-digit 7-segment displays usually require 12 connection pins. But the TM1637 IC is
mounted on the back of the display module, which reduces the total wire to 4. Two pins are required
for the power connections and the other two pins are used to control the segments.
Specification:
1. Driver IC: TM1637
2. Size: 30mm x 14mm
3. Display Color: Red
4. Connection to an Arduino UNO:




Connect VCC to GPIO 5v
Connect GND to GPIO GND
Connect CLK to any GPIO pin
Connect DIO to any GPIO pin
2. WHY IS TM1637 ESSENTIAL.
The TM1637 supports many functions – including ON/OFF and brightness control of the LEDs as well
as accessing each of the segments. It also allows you to adjust the brightness of the LEDs at software
level. And another good thing is that once the display is updated by the microcontroller, the TM1637
then takes care of all the work of refreshing the display. Thereby removing the overhead from the
microcontroller, which can be off doing other important things. The TM1637 module includes four
0.36 segment 7-segment displays to display sensor data or temperature. In addition to the four 7segments, the module has a ‘colon’ at the center which makes it very easy to create clock or timebased projects.
Download