Counter With LED Matrix | Arduino Project

Introduction

In this tutorial, we will create a simple Counter With LED Matrix | Arduino Project, counter using an Arduino UNO and two 8×8 Dot Matrix MAX7219 modules. The counter will increment or decrement based on the input from a push button. The MAX7219 modules will display the count using LED matrices, making it visually appealing and easy to read. With the help of a 1M ohm resistor, we will debounce the push button to ensure accurate counting. Let’s get started with the step-by-step guide to build this fun and interactive project.

Hardware Required

You will require the following Hardware Components for the Counter With LED Matrix | Arduino Project.

Components#Buy From Amazon
Arduino UNO1Buy Now
8×8 Dot Matrix MAX72192Buy Now
Push Button1Buy Now
9v DC Adapter (Optional)1Buy Now
Resistor 1M1Buy Now
Jumper WiresFewBuy Now
Breadboard1Buy Now

What is 8×8 Dot Matrix MAX7219?

The topic of our project is the creation of a basic counter using an Arduino UNO and two 8×8 Dot Matrix MAX7219 modules. The primary goal is to enable users to increment or decrement the count by pressing a single push button, while the LED matrices visually represent the count. The project showcases the power of Arduino’s versatility and the MAX7219’s ability to create appealing LED matrix displays. Through this hands-on experience, beginners can understand how to integrate different components, work with libraries, and build an interactive counter that engages the user with every button press.

Pinout

8x8-Dot-Matrix-Display-Module-Pinout

Pin Configuration

Pin TypePin Description
Vcc5V Input Voltage
GNDGround
CSChip Select
CLKClock
DINData-In
DOUTData Out (Use for Multiple Display Interfacing)

Specifications

  1. High-resolution LED matrices: The 8×8 Dot Matrix MAX7219 modules provide high-resolution display capabilities, ensuring a clear and visually appealing count representation.
  2. Efficient power consumption: Both the Arduino UNO and MAX7219 modules consume minimal power, making the counter an energy-efficient solution.
  3. User-friendly push-button: The push button allows users to effortlessly increment or decrement the count, making it a simple and intuitive user interface.
  4. Accurate debounce mechanism: The 1M ohm resistor integrated into the circuit ensures accurate counting by debouncing the push button, preventing multiple counts from a single press.
  5. Seamless integration with Arduino UNO: The MAX7219 modules are compatible with Arduino UNO, allowing for easy integration and control of the LED matrices.

Features

  1. Visual appeal: The LED matrix display creates an engaging and visually appealing representation of the count, making the counter enjoyable to use.
  2. Reset function: The counter resets automatically when it reaches its maximum or minimum value, ensuring continuous functionality without manual intervention.
  3. Real-time counting: Users can observe the count increase or decrease in real-time as they press the push button, adding a sense of interactivity.
  4. Customization options: The code can be easily customized to adjust counting speed, add animations, or incorporate sound effects, allowing for creative experimentation.
  5. Versatile applications: The interactive counter can find applications in various projects, such as game scores, timers, or even tallying items.

Circuit Diagram

The following circuit shows you the connection of the Counter With LED Matrix | Arduino Tutorial, Please make the connection carefully

Counter-With-LED-Matrix-Arduino-Circuit

Installing Arduino IDE Software

First, you will require to Download the updated version of Arduino IDE Software and Install it on your PC or laptop. if you Learn How to install the Arduino step-by-step guide then click on how to install Arduino Button given Blow

Installing Libraries

Now when you are Ready to upload the code, to the Arduino Board you will need first to add the Following Libraries in Arduino, If you Learn How to add the library in the Arduino step-by-step guide click on how to install the library Button given Blow

Code

//For more Projects: www.arduinocircuit.com

const int buttonPin = 7; // the pin that the pushbutton is attached to
int buttonPushCounter = 0; // counter for the number of button presses
int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button
int jumlah=0;
#include “LedControl.h”

LedControl lc=LedControl(12,11,10,2); // Pins: DIN,CLK,CS, # of Display connected

unsigned long delayTime=1000; // Delay between Frames

// Put values in arrays

byte one[] =
{
B00000000, // First frame of invader #1
B00000000,
B10000010,
B11111111,
B10000000,
B00000000,
B00000000,
B00000000
};
byte two[] =
{
B00000000, // First frame of invader #1
B00000000,
B11000010,
B10100001,
B10010001,
B10001001,
B10000110,
B00000000
};
byte three[] =
{
B00000000, // First frame of invader #1
B01000010,
B10000001,
B10001001,
B10001001,
B01110110,
B00000000,
B00000000
};
byte four[] =
{
B00000000, // First frame of invader #1
B00110000,
B00101000,
B00100100,
B00100010,
B11110001,
B00100000,
B00000000
};
byte five[] =
{
B00000000, // First frame of invader #1
B00000000,
B01001111,
B10001001,
B10001001,
B10001001,
B01110001,
B00000000
};
byte six[] =
{
B00000000, // First frame of invader #1
B00000000,
B01111110,
B10001001,
B10001001,
B10001001,
B01110010,
B00000000
};
byte seven[] =
{
B00000000, // First frame of invader #1
B00000000,
B10000001,
B01000001,
B00100001,
B00010001,
B00001111,
B00000000
};
byte eight[] =
{
B00000000, // First frame of invader #1
B00000000,
B01110110,
B10001001,
B10001001,
B10001001,
B01110110,
B00000000
};
byte nine[] =
{
B00000000, // First frame of invader #1
B00000000,
B01000110,
B10001001,
B10001001,
B10001001,
B01111110,
B00000000
};
byte zero[] =
{
B00000000, // First frame of invader #1
B00000000,
B01111110,
B10000001,
B10000001,
B10000001,
B01111110,
B00000000
};

void setup() {
// initialize the button pin as a input:
pinMode(buttonPin, INPUT);
// initialize serial communication:
Serial.begin(9600);
lc.shutdown(0,false); // Wake up displays
lc.shutdown(1,false);
lc.setIntensity(0,0); // Set intensity levels
lc.setIntensity(1,0);
lc.clearDisplay(0); // Clear Displays
lc.clearDisplay(1);
}

void sone()
{
for (int i = 0; i < 8; i++)
{
lc.setRow(0,i,one[i]);
}
}
void stwo()
{
for (int i = 0; i < 8; i++)
{
lc.setRow(0,i,two[i]);
}
}
void sthree()
{
for (int i = 0; i < 8; i++)
{
lc.setRow(0,i,three[i]);
}
}
void sfour()
{
for (int i = 0; i < 8; i++)
{
lc.setRow(0,i,four[i]);
}
}
void sfive()
{
for (int i = 0; i < 8; i++)
{
lc.setRow(0,i,five[i]);
}
}
void ssix()
{
for (int i = 0; i < 8; i++)
{
lc.setRow(0,i,six[i]);
}
}
void sseven()
{
for (int i = 0; i < 8; i++)
{
lc.setRow(0,i,seven[i]);
}
}
void seight()
{
for (int i = 0; i < 8; i++)
{
lc.setRow(0,i,eight[i]);
}
}
void snine()
{
for (int i = 0; i < 8; i++)
{
lc.setRow(0,i,nine[i]);
}
}
void szero()
{
for (int i = 0; i < 8; i++)
{
lc.setRow(0,i,zero[i]);
}
}

void sone1()
{
for (int i = 0; i < 8; i++)
{
lc.setRow(1,i,one[i]);
}
}
void stwo1()
{
for (int i = 0; i < 8; i++)
{
lc.setRow(1,i,two[i]);
}
}
void sthree1()
{
for (int i = 0; i < 8; i++)
{
lc.setRow(1,i,three[i]);
}
}
void sfour1()
{
for (int i = 0; i < 8; i++)
{
lc.setRow(1,i,four[i]);
}
}
void sfive1()
{
for (int i = 0; i < 8; i++)
{
lc.setRow(1,i,five[i]);
}
}
void ssix1()
{
for (int i = 0; i < 8; i++)
{
lc.setRow(1,i,six[i]);
}
}
void sseven1()
{
for (int i = 0; i < 8; i++)
{
lc.setRow(1,i,seven[i]);
}
}
void seight1()
{
for (int i = 0; i < 8; i++)
{
lc.setRow(1,i,eight[i]);
}
}
void snine1()
{
for (int i = 0; i < 8; i++)
{
lc.setRow(1,i,nine[i]);
}
}
void szero1()
{
for (int i = 0; i < 8; i++)
{
lc.setRow(1,i,zero[i]);
}
}

void sepuluh()
{
lc.clearDisplay(0);
lc.clearDisplay(1);
stwo1();
sone();
}

void loop() {
// read the pushbutton input pin:
buttonState = digitalRead(buttonPin);

// compare the buttonState to its previous state
if (buttonState != lastButtonState) {
// if the state has changed, increment the counter
if (buttonState == HIGH) {
// if the current state is HIGH then the button
// wend from off to on:
buttonPushCounter++;
Serial.println(“on”);
Serial.print(“number of button pushes: “);
Serial.println(buttonPushCounter);

// Delay a little bit to avoid bouncing
delay(100);
}
int jumlah = buttonPushCounter;
if (jumlah==1){
lc.clearDisplay(0);
lc.clearDisplay(1);
szero1();
sone();
}
if (jumlah==2){
lc.clearDisplay(0);
lc.clearDisplay(1);
szero1();
stwo();
}
if (jumlah==3){
lc.clearDisplay(0);
lc.clearDisplay(1);
szero1();
sthree();
}
if (jumlah==4){
lc.clearDisplay(0);
lc.clearDisplay(1);
szero1();
sfour();
}
if (jumlah==5){
lc.clearDisplay(0);
lc.clearDisplay(1);
szero1();
sfive();
}
if (jumlah==6){
lc.clearDisplay(0);
lc.clearDisplay(1);
szero1();
ssix();
}
if (jumlah==7){
lc.clearDisplay(0);
lc.clearDisplay(1);
szero1();
sseven();
}
if (jumlah==8){
lc.clearDisplay(0);
lc.clearDisplay(1);
szero1();
seight();
}
if (jumlah==9){
lc.clearDisplay(0);
lc.clearDisplay(1);
szero1();
snine();
}
if (jumlah==10){
lc.clearDisplay(0);
lc.clearDisplay(1);
sone1();
szero();
}
if (jumlah==11){
lc.clearDisplay(0);
lc.clearDisplay(1);
sone1();
sone();
}
if (jumlah==12){
lc.clearDisplay(0);
lc.clearDisplay(1);
sone1();
stwo();
}
if (jumlah==13){
lc.clearDisplay(0);
lc.clearDisplay(1);
sone1();
sthree();
}
if (jumlah==14){
lc.clearDisplay(0);
lc.clearDisplay(1);
sone1();
sfour();
}
if (jumlah==15){
lc.clearDisplay(0);
lc.clearDisplay(1);
sone1();
sfive();
}
if (jumlah==16){
lc.clearDisplay(0);
lc.clearDisplay(1);
sone1();
ssix();
}
if (jumlah==17){
lc.clearDisplay(0);
lc.clearDisplay(1);
sone1();
sseven();
}
if (jumlah==18){
lc.clearDisplay(0);
lc.clearDisplay(1);
sone1();
seight();
}
if (jumlah==19){
lc.clearDisplay(0);
lc.clearDisplay(1);
sone1();
snine();
}
if (jumlah==20){
lc.clearDisplay(0);
lc.clearDisplay(1);
stwo1();
szero();
}
if (jumlah==21){
lc.clearDisplay(0);
lc.clearDisplay(1);
stwo1();
sone();
}
if (jumlah==22){
lc.clearDisplay(0);
lc.clearDisplay(1);
stwo1();
stwo();
}
if (jumlah==23){
lc.clearDisplay(0);
lc.clearDisplay(1);
stwo1();
sthree();
}
if (jumlah==24){
lc.clearDisplay(0);
lc.clearDisplay(1);
stwo1();
sfour();
}
if (jumlah==25){
lc.clearDisplay(0);
lc.clearDisplay(1);
stwo1();
sfive();
}
if (jumlah==26){
lc.clearDisplay(0);
lc.clearDisplay(1);
stwo1();
ssix();
}
if (jumlah==27){
lc.clearDisplay(0);
lc.clearDisplay(1);
stwo1();
sseven();
}
if (jumlah==28){
lc.clearDisplay(0);
lc.clearDisplay(1);
stwo1();
seight();
}
if (jumlah==29){
lc.clearDisplay(0);
lc.clearDisplay(1);
stwo1();
snine();
}
if (jumlah==30){
lc.clearDisplay(0);
lc.clearDisplay(1);
sthree1();
szero();
}
if (jumlah==31){
lc.clearDisplay(0);
lc.clearDisplay(1);
sthree1();
sone();
}
if (jumlah==32){
lc.clearDisplay(0);
lc.clearDisplay(1);
sthree1();
stwo();
}
if (jumlah==33){
lc.clearDisplay(0);
lc.clearDisplay(1);
sthree1();
sthree();
}
if (jumlah==34){
lc.clearDisplay(0);
lc.clearDisplay(1);
sthree1();
sfour();
}
if (jumlah==35){
lc.clearDisplay(0);
lc.clearDisplay(1);
sthree1();
sfive();
}
if (jumlah==36){
lc.clearDisplay(0);
lc.clearDisplay(1);
sthree1();
ssix();
}
if (jumlah==37){
lc.clearDisplay(0);
lc.clearDisplay(1);
sthree1();
sseven();
}
if (jumlah==38){
lc.clearDisplay(0);
lc.clearDisplay(1);
sthree1();
seight();
}
if (jumlah==39){
lc.clearDisplay(0);
lc.clearDisplay(1);
sthree1();
snine();
}
if (jumlah==40){
lc.clearDisplay(0);
lc.clearDisplay(1);
sfour1();
szero();
}
if (jumlah==41){
lc.clearDisplay(0);
lc.clearDisplay(1);
sfour1();
sone();
}
if (jumlah==42){
lc.clearDisplay(0);
lc.clearDisplay(1);
sfour1();
stwo();
}
if (jumlah==43){
lc.clearDisplay(0);
lc.clearDisplay(1);
sfour1();
sthree();
}
if (jumlah==44){
lc.clearDisplay(0);
lc.clearDisplay(1);
sfour1();
sfour();
}
if (jumlah==45){
lc.clearDisplay(0);
lc.clearDisplay(1);
sfour1();
sfive();
}
if (jumlah==46){
lc.clearDisplay(0);
lc.clearDisplay(1);
sfour1();
ssix();
}
if (jumlah==47){
lc.clearDisplay(0);
lc.clearDisplay(1);
sfour1();
sseven();
}
if (jumlah==48){
lc.clearDisplay(0);
lc.clearDisplay(1);
sfour1();
seight();
}
if (jumlah==49){
lc.clearDisplay(0);
lc.clearDisplay(1);
sfour1();
snine();
}
if (jumlah==50){
lc.clearDisplay(0);
lc.clearDisplay(1);
sfive1();
szero();
}

if (jumlah==0){
lc.clearDisplay(0);
lc.clearDisplay(1);
//szero1();
//sone();
}

}

lastButtonState = buttonState;

}

Applications

  1. Game score tracker: The counter can be used in games to keep track of scores, providing a fun and interactive gaming experience.
  2. Countdown timer: By modifying the code, the counter can function as a countdown timer for various activities and events.
  3. Classroom activity: Teachers can use the counter in classrooms to track student participation or as a reward system for positive behavior.
  4. Product inventory tracker: Businesses can implement the counter as an inventory tracker, keeping tabs on the stock of items.
  5. Physical fitness counter: The counter can be integrated into fitness equipment to track exercise repetitions or workout duration.

Conclusion

Congratulations! You have successfully built a captivating LED matrix counter using an Arduino UNO and MAX7219 modules. This project has introduced you to the exciting world of Arduino and its endless possibilities for creative and interactive projects. The visual appeal of the LED matrix and the intuitive push-button interface make the counter a delightful experience for users of all levels.

Leave a Comment


error: