Practical No. 6: Interface 4 4 LED Matrix With AVR and Develop A C Program To Display Various Patterns. Aim
Practical No. 6: Interface 4 4 LED Matrix With AVR and Develop A C Program To Display Various Patterns. Aim
Practical No. 6: Interface 4 4 LED Matrix With AVR and Develop A C Program To Display Various Patterns. Aim
6: Interface 4*4 LED matrix with AVR and develop a C program to display
various patterns.
Aim : To interface a 4x4 LED matrix with an AVR microcontroller and develop a C program to display
various patterns on the matrix.
Objective:
Materials Needed:
AVR microcontroller (e.g., ATmega328P)
16 Red LED
16 220 Ω Resistor
Procedure:
Initialization (setup function):
.
1 2 3 4 5 6
R1 R2 R4 R3 R6 R7
220 D16 D15 220 D14 220 D13 220 D12 220 220 D11
RED RED RED RED RED RED
A A
U1_D5
U1_D4
U1_D3
U1_D2
U1_TX
U1_RX
U1_GND
U1_GND
U1
VIN RX
B 5V TX B
3.3V D2
D3
AREF D4
IOREF D5
RES D6
D7
A0
Arduino D8
R8 R9 R10 R11
A1
UNO D9
220 220 A2 D10 220 220
D10 D9 D8 D7
RED RED A3 D11 RED RED
A4 D12
A5 D13
SDA
GND SCL
C U1_RX
C
U1_TX
U1_D2
U1_D3
U1_D4
U1_D5
U1_A0
U1_A1
U1_D10
U1_D11
U1_D12
U1_D13
U1_GND
D D
U1_A0
U1_A1
U1_D13
U1_D12
U1_D11
U1_D10
U1_GND
E E
Flow Chart:
Code:
int a = 100;
int b = 300;
void setup()
{
pinMode(0, OUTPUT);
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
}
void loop()
{
digitalWrite(0, HIGH);
delay(a);
digitalWrite(0, LOW);
delay(a);
digitalWrite(1, HIGH);
delay(a);
digitalWrite(1, LOW);
delay(a);
digitalWrite(2, HIGH);
delay(a);
digitalWrite(2, LOW);
delay(a);
digitalWrite(3, HIGH);
delay(a);
digitalWrite(3, LOW);
delay(a);
digitalWrite(4, HIGH);
delay(a);
digitalWrite(4, LOW);
delay(a);
digitalWrite(5, HIGH);
delay(a);
digitalWrite(5, LOW);
delay(a);
digitalWrite(6, HIGH);
delay(a);
digitalWrite(6, LOW);
delay(a);
digitalWrite(7, HIGH);
delay(a);
digitalWrite(7, LOW);
delay(a);
digitalWrite(8, HIGH);
delay(a);
digitalWrite(8, LOW);
delay(a);
digitalWrite(9, HIGH);
delay(a);
digitalWrite(9, LOW);
delay(a);
digitalWrite(10, HIGH);
delay(a);
digitalWrite(10, LOW);
delay(a);
digitalWrite(11, HIGH);
delay(a);
digitalWrite(11, LOW);
delay(a);
digitalWrite(12, HIGH);
delay(a);
digitalWrite(12, LOW);
delay(a);
digitalWrite(13, HIGH);
delay(a);
digitalWrite(13, LOW);
delay(a);
digitalWrite(A0, HIGH);
delay(a);
digitalWrite(A0, LOW);
delay(a);
digitalWrite(A1, HIGH);
delay(a);
digitalWrite(A1, LOW);
delay(a);
digitalWrite(A1, HIGH);
delay(a);
digitalWrite(A1, LOW);
delay(a);
digitalWrite(A0, HIGH);
delay(a);
digitalWrite(A0, LOW);
delay(a);
digitalWrite(13, HIGH);
delay(a);
digitalWrite(13, LOW);
delay(a);
digitalWrite(12, HIGH);
delay(a);
digitalWrite(12, LOW);
delay(a);
digitalWrite(11, HIGH);
delay(a);
digitalWrite(11, LOW);
delay(a);
digitalWrite(10, HIGH);
delay(a);
digitalWrite(10, LOW);
delay(a);
digitalWrite(9, HIGH);
delay(a);
digitalWrite(9, LOW);
delay(a);
digitalWrite(8, HIGH);
delay(a);
digitalWrite(8, LOW);
delay(a);
digitalWrite(7, HIGH);
delay(a);
digitalWrite(7, LOW);
delay(a);
digitalWrite(6, HIGH);
delay(a);
digitalWrite(6, LOW);
delay(a);
digitalWrite(5, HIGH);
delay(a);
digitalWrite(5, LOW);
delay(a);
digitalWrite(4, HIGH);
delay(a);
digitalWrite(4, LOW);
delay(a);
digitalWrite(3, HIGH);
delay(a);
digitalWrite(3, LOW);
delay(a);
digitalWrite(2, HIGH);
delay(a);
digitalWrite(2, LOW);
delay(a);
digitalWrite(1, HIGH);
delay(a);
digitalWrite(1, LOW);
delay(a);
digitalWrite(0, HIGH);
delay(a);
digitalWrite(0, LOW);
delay(b);
digitalWrite(0, HIGH);
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(6, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
digitalWrite(12, HIGH);
digitalWrite(13, HIGH);
digitalWrite(A0, HIGH);
digitalWrite(A1, HIGH);
delay(b);
digitalWrite(0, LOW);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(6, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
digitalWrite(A0, LOW);
digitalWrite(A1, LOW);
delay(b);
digitalWrite(0, HIGH);
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(6, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
digitalWrite(12, HIGH);
digitalWrite(13, HIGH);
digitalWrite(A0, HIGH);
digitalWrite(A1, HIGH);
delay(b);
digitalWrite(0, LOW);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(6, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
digitalWrite(A0, LOW);
digitalWrite(A1, LOW);
delay(b);
}
Results:
Interpretation of Results:
The experiment effectively demonstrated the integration of a 4x4 LED matrix with an AVR
microcontroller. Various patterns such as Sequential blinking from bottom to top, Sequential blinking
from top to bottom, Blinking all pins simultaneously ON and OFF, Repeat blinking of all pins were
displayed accurately. The LED matrix functioned as expected, with clear patterns and minimal issues,
validating the successful implementation of both the hardware and software components.
Conclusion:
The project achieved its goals by successfully interfacing the 4x4 LED matrix with the AVR
microcontroller and displaying various patterns using a C program. This demonstrated the
microcontroller's capability to control visual outputs and provided insights into practical applications.
Future improvements could focus on enhancing display resolution and adding interactive features.