Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Teensy 4.0 and MAX7219-Based 7-Segment Display Counter

View and Edit Project In Cirkit DesignerImage of Teensy 4.0 and MAX7219-Based 7-Segment Display Counter

Circuit Documentation

Summary

This circuit is designed to control a 7-segment display using a Teensy 4.0 microcontroller and a MAX7219 display driver. The circuit includes additional components such as a SN74AHCT125N buffer, resistors, and capacitors to ensure proper operation and signal integrity. The Teensy 4.0 runs a program to display numbers from 0 to 999 on the 7-segment displays.

Component List

  1. Teensy 4.0

    • Description: Microcontroller used to control the display.
    • Pins: 5V, GND, 3V, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
  2. 7-segment Display

    • Description: Display used to show numbers.
    • Pins: A, B, C, D, E, F, G, COM, dot
  3. SN74AHCT125N

    • Description: Quad buffer/line driver with 3-state outputs.
    • Pins: 1OE, 1A, 1Y, 2OE, 2A, 2Y, GND, Vcc, 4OE, 4A, 4Y, 3OE, 3A, 3Y
  4. MAX7219

    • Description: Display driver for 7-segment displays.
    • Pins: DOUT, SEG D, SEG DP, SEG E, SEG C, V+, ISET, SEG G, SEG B, SEG F, SEG A, CLK, LOAD(CSn), DIG 1, DIG 5, GND, DIG 7, DIG 3, DIG 2, DIG 6, DIG 4, DIG 0, DIN
  5. Ceramic Capacitor

    • Description: Capacitor used for filtering and stabilization.
    • Pins: pin0, pin1
    • Properties: Capacitance: 100nF
  6. Resistor

    • Description: Resistor used for current limiting.
    • Pins: pin1, pin2
    • Properties: Resistance: 33kΩ

Wiring Details

Teensy 4.0

7-segment Display

SN74AHCT125N

MAX7219

Ceramic Capacitor

Resistor

Code Documentation

#include <LedControl.h>

// Define control pins (match these to your Teensy connections)
const int DIN_PIN = 4;    // Data In
const int CLK_PIN = 2;    // Clock
const int CS_PIN = 3;     // Load/CS

// Initialize LedControl object
// Parameters: DIN_PIN, CLK_PIN, CS_PIN, number of MAX7219 devices
LedControl lc = LedControl(DIN_PIN, CLK_PIN, CS_PIN, 1);

void setup() {
  // Wake up MAX7219 from power-saving mode
  lc.shutdown(0, false);
  // Set brightness (0-15)
  lc.setIntensity(0, 8);
  // Clear display
  lc.clearDisplay(0);
}

void loop() {
  // Display numbers from 0 to 999
  for (int number = 0; number <= 999; number++) {
    displayNumber(number);
    delay(500);
  }
}

void displayNumber(int number) {
  int digit;
  // Loop through each digit
  for (int position = 0; position < 3; position++) {
    // Get the digit value
    digit = number % 10;
    // Set the digit on the display
    lc.setDigit(0, position, digit, false);
    // Move to the next digit
    number /= 10;
  }
}

This code initializes the MAX7219 display driver and sets up the Teensy 4.0 to display numbers from 0 to 999 on the 7-segment displays. The setup function configures the MAX7219, and the loop function continuously updates the display with new numbers. The displayNumber function breaks down the number into individual digits and displays them on the 7-segment displays.