This project showcases a heartbeat-flowing light effect on an 8x8 LED matrix using an Arduino UNO development board.
Arduino UNO Development Board: The central processing unit controls the LED matrix.
LEDs (64): Arranged in an 8x8 grid to form the matrix display.
100Ω Resistors (8): Used to limit the current flowing through each LED, preventing damage and ensuring consistent brightness.
Code AnalysisThe code is structured into several key sections: defining pin connections, setting up the Arduino board, the main loop for the heartbeat effect, and functions to control the LED matrix.
1. Pin Definitions:
led_row and led_col arrays define the pins connected to the rows and columns of the LED matrix, respectively.
2. LED Coordinates:
The code[] array stores the coordinates of the LEDs that need to be lit to create the heart shape. Each pair of numbers represents the (y, x) coordinates.
3. Setup Function:
Initializes all the row and column pins as outputs, setting the stage for controlling the LED matrix.
4. Loop Function:
The loop() function contains the logic for the heartbeat effect. It iterates through the code[] array in two directions: forward to create the heartbeat effect and backward to return to the initial state, creating a continuous loop.
5. Reset Function:
reset_all() turns off the entire LED matrix by setting all row pins low and all column pins high.
6. Display Function:
display() lights up the LED at the specified coordinates. It first calls reset_all() to ensure the matrix is clear before lighting up the specified LED.
7. Speed Adjustment:
The delay(50) in the display() function adjusts the speed of the heartbeat effect. This can be modified to make the effect faster or slower.
How It WorksWhen the Arduino board is powered and the code is executed, the loop() function continuously iterates through the code[] array, lighting up LEDs in a sequence that forms a heart shape. The forward and backward iteration through the array creates the effect of the heart "beating." The reset_all() function ensures that the matrix is cleared before each new heartbeat cycle, and the display() function manages the individual lighting of LEDs based on their coordinates.
Start your circuit simulation at PCBX -
https://www.pcbx.com/forum?mtm_campaign=E&mtm_kwd=hack
Get your first free PCB & PCBA prototyping here
Comments