Introduction: Countdown Timer(Minutes and Seconds) With Arduino and TM1637 4-Digit 7-Segment Display.

In this project, we will make a Countdown timer(in Minutes and Seconds) with Arduino and 4-Bit 7-Segement display.

Supplies

  1. Arduino Nano
  2. TM1637 4-Digit 7-Segment Display
  3. Breadboard
  4. Connecting Wire

Step 1: Gather the Components

  1. Arduino board (e.g., Arduino Nano)
  2. TM1637 display module
  3. Jumper wires
  4. Breadboard

Step 2: Connect the Components

  1. Connect the CLK pin of the TM1637 display module to any digital pin on the Arduino (e.g., pin 2).
  2. Connect the DIO pin of the TM1637 display module to another digital pin on the Arduino (e.g., pin 3).
  3. Ensure the power and ground connections are properly made between the Arduino and the TM1637 display module.

Step 3: Install the TM1637Display Library

  1. Open the Arduino IDE software.
  2. Go to "Sketch" -> "Include Library" -> "Manage Libraries".
  3. In the Library Manager, search for "TM1637Display".
  4. Select the TM1637Display library by avishorp and click "Install".

Step 4: Open a New Sketch

  • Open a new Arduino sketch in the IDE.

Step 5: Copy and Paste the Code

#include <TM1637Display.h>


// Countdown Timer
const unsigned long COUNTDOWN_TIME = 300; // 5 minutes in seconds


// Pins for TM1637 display module
#define CLK_PIN 2
#define DIO_PIN 3


TM1637Display display(CLK_PIN, DIO_PIN);


unsigned long startTime;
unsigned long currentTime;
unsigned long elapsedTime;


void setup() {
  display.setBrightness(7); // Set the brightness of the display (0-7)
  display.clear(); // Clear the display
  startTime = millis(); // Record the starting time
}


void loop() {
  currentTime = millis(); // Get the current time
  elapsedTime = (currentTime - startTime) / 1000; // Calculate elapsed time in seconds


  if (elapsedTime <= COUNTDOWN_TIME) {
    unsigned long remainingTime = COUNTDOWN_TIME - elapsedTime;


    // Display remaining time in Minutes:Seconds format
    unsigned int minutes = remainingTime / 60;
    unsigned int seconds = remainingTime % 60;
    display.showNumberDecEx(minutes * 100 + seconds, 0b01000000, true);


    if (remainingTime == 0) {
      // Start blinking when countdown reaches 00:00
      while (true) {
        display.showNumberDecEx(0, 0b01000000, true); // Display "00:00"
        delay(500);
        display.clear(); // Clear the display
        delay(500);
      }
    }
  }


  delay(1000); // Wait for 1 second
}


Step 6: Verify and Upload the Sketch

  1. Verify that the code compiles without any errors by clicking the "Verify" button (checkmark icon) in the Arduino IDE.
  2. Once the code is successfully verified, upload it to the Arduino board by clicking the "Upload" button (right-arrow icon).

Step 7: Test the Countdown Timer

  1. After uploading the code to the Arduino, the countdown timer will start immediately.
  2. The TM1637 display module will show the remaining time in the Minutes: Seconds format.
  3. When the countdown reaches 00:00, the display will continuously blink "00:00" with a 0.5-second interval.

Step 8: Conclusion

That's it! You have successfully created a countdown timer using an Arduino and a TM1637 display. The display will show the remaining time in the Minutes:Seconds format and blink continuously at the end of the timer.