CODE | TM1637 4Digital 7Segment Display Module - Arduino Project 034

RonWang2 years ago (2024-06-14)电子编程 COD79

A standard 4-digit 7-segment display is needed for clock, timer and counter projects, but it usually requires 12 connections. The TM1637 module makes it easier by only requiring 4 connections: 2 for power and 2 for controlling the segments.

A TM1637 module typically consists of four 7-segment LEDs and a colon-shaped LED in the middle: It is ideal for displaying time in hours and minutes, or minutes and seconds, or scores of two teams.

Project 34 Interfacing TM1637 4 Digital 7 Segment Display Module

TM1637 Digital.webp

4 Digital 7 Segment Display

Arduino TM1637 Digital Circuit

TM1637 4 Digital 7 Segment Display Circuit

Arduino TM1637 Digital Schematic


TM1637 4 Digital 7 Segment Display Schematic

/* Coding Ron Wang
   Nov.27th 2024
   Autaba support for coding hardware
   Project 034 TM1637 4 digit 7 segment display with Arduino.
 */

#include "TM1637Display.h"   
#define CLK 2
#define DIO 3
TM1637Display display = TM1637Display(CLK, DIO);  // Create display object of type TM1637 Display
const uint8_t data[] = {0xff, 0xff, 0xff, 0xff};  // Create array that turns all segments on
const uint8_t blank[] = {0x00, 0x00, 0x00, 0x00}; // Create array that turns all segments off
// You can set the individual segments per digit to spell words or create other symbols 
const uint8_t DONE[] = {
  SEG_B | SEG_C | SEG_D | SEG_E | SEG_G,           // d
  SEG_A | SEG_B | SEG_C | SEG_D | SEG_E | SEG_F,   // O
  SEG_C | SEG_E | SEG_G,                           // n
  SEG_A | SEG_D | SEG_E | SEG_F | SEG_G            // E
};
// Create degree Celsius symbol:
const uint8_t celsius[] = {
  SEG_A | SEG_B | SEG_F | SEG_G,  // Circle
  SEG_A | SEG_D | SEG_E | SEG_F   // C
};

void setup() {
  // Clear the display:
  display.clear();
  delay(1000);
}

void loop() {
  // Set the brightness:
  display.setBrightness(7);
  // All segments on:
  display.setSegments(data);
  delay(1000);
  display.clear();
  delay(1000);
  // Show counter:
  int i;
  for (i = 0; i < 101; i++) {
    display.showNumberDec(i);
    delay(50);
  }
  delay(1000);
  display.clear();
  delay(1000);
  // Print number in different locations, loops 2 times:
  int j;
  for (j = 0; j < 2; j++) {
    for (i = 0; i < 4; i++) {
      display.showNumberDec(i, false, 1, i);
      delay(500);
      display.clear();
    }
  }
  
  delay(1000);
  display.clear();
  delay(1000);
  // Set brightness (0-7):
  int k;
  for (k = 0; k < 8; k++) {
    display.setBrightness(k);
    display.setSegments(data);
    delay(500);
  }
  delay(1000);
  display.clear();
  delay(1000);
  // Print 1234 with the center colon:
  display.showNumberDecEx(1234, 0b11100000, false, 4, 0);
  delay(1000);
  display.clear();
  delay(1000);
  int temperature = 24;
  display.showNumberDec(temperature, false, 2, 0);
  display.setSegments(celsius, 2, 2);
  delay(1000);
  display.clear();
  delay(1000);
  display.setSegments(DONE);
  while(1);
}
Share with Friends:

Related Articles

CODE | LED Traffic Light - Arduino Project 003

CODE | LED Traffic Light - Arduino Project 003

You are now going to create a set of traffic lights that will change from green to red, via amber, a…

How to use the Soldering Electric Maker Basic Technology

How to use the Soldering Electric Maker Basic Technology

如何使用电络铁?初级电子制作与维修之焊接知识Gather Tools: You will need a soldering iron, solder, a soldering iron stand,…

CODE | Liquid Crystal Displays-Serial to Display - Arduino Project 023C

CODE | Liquid Crystal Displays-Serial to Display - Arduino Project 023C

Before wiring the LCD screen to your Arduino board we suggest to solder a pin header strip to the 14…

About Arduino Resources

About Arduino Resources

The Arduino platform benefits from an active user community that makes it easy to get help from fell…

DIY - Monochrome Light Cube Maker Introduction Step by Step

DIY - Monochrome Light Cube Maker Introduction Step by Step

First, let's take a look at the complete welded diagram (the shell needs to be purchased separat…

Setting Up the Environment for Aliun Server

Setting Up the Environment for Aliun Server

阿里云服务器的环境搭建与调试从阿里云产品发布开始便一直在使用ECM云服务器,但是之前多使用的是Windows系统,后来摸索开始挑战自己使用CentOS系统,靠着几行程序和网上各位大咖的教程和分享,竟然…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.