Seven Segment Display and Keypad

The Seven Segment Display and its TM1637 controller

There is a nice and simple seven segment display controlled by a TM1637 controller, which can be used e.g. as a clock display. It provides 4 digits and a colon dividing digits 1 and 2 from digits 3 and 4, such that the first two digits can be used to display hours, the last two digits to display minutes and the colon can be set blinking at a 1 Hz rate. Of course you can also use it for other purposes like displaying the voltage values of a voltmeter.

seven_seg_front.png seven_seg_back.png

As can be seen from the back view of the module, interfacing to the ESP32 is pretty simple. Here are the connections I use:

Pins on display module Pins on ESP32
CLK D1: GPIO 22
DIO D2: GPIO 21
VCC 3.3V
GND GND
The data sheet for the TM1637 controller can be found at https://www.mcielectronics.cl/website_MCI/static/documents/Datasheet_TM1637.pdf.

The TM1637 uses a proprietary 2-wire serial protocol with a data line (dio) and a clock line.

Exercise 1:

Carefully read the data sheet.

Write a driver implementing the serial protocol. Check the acknowledge signal from the controller to make sure the data have been correctly transmitted. The signals on the dio and the clk lines must be programmed setting the corresponding GPIO pins. Serialization is also done in software.
Write a test routine that displays 1234 on the seven segment digits.

Exercise 2:

Modify exercise 1 to implement a blinking colon

Exercise 3:

Read the current time from the ntp and implement a clock displaying hours and minutes. Make the colon blink at a 1 Hz rate.

The Keypad

The keypad has a total of 16 switches. These are connected to 8 pins organized as 4 rows and 4 columns.

keypad.png 4X4-Keypad-Schematic.png
The job will be to find out which column makes a connection to which row in order to find out which switch is closed. This can be done by connecting e.g. the 4 row pins to GPIO outputs and the 4 column pins to GPIO inputs with pull-ups.

Set the first row pin to low and check on each column pin if you read a zero. If you do, you have found the switch closed. If not, continue the same procedure on the other row pins.

Comments

Topic attachments
I Attachment History Action Size Date Who Comment
PNGpng 4X4-Keypad-Schematic.png r1 manage 14.6 K 2021-01-20 - 21:58 UliRaich  
PNGpng keypad.png r1 manage 115.6 K 2021-01-20 - 21:41 UliRaich  
PNGpng seven_seg_back.png r1 manage 117.4 K 2021-01-20 - 21:40 UliRaich  
PNGpng seven_seg_front.png r1 manage 115.2 K 2021-01-20 - 21:40 UliRaich  
Edit | Attach | Watch | Print version | History: r7 | r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r1 - 2021-01-20 - UliRaich
 
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback