|
22. MAX7219/MAX7221: Control two independent 7-segment display
 | Arduino Nano |
 | Breadboard |
 | 7 segment display
Type: 5161AB, Blue, Common Cathode, 0.56 inch |
|
 | Capacitor, 10 µF 25V |
 | MAX7221
pdf |
 | Wire |
 | Resistor 10K ohm |
|
Capacitor 5v rail <=> gnd rail
Arduino Nano
- 5v <=> 5v rail
- gnd <=> gnd rail
|
|
Arduino Nano <=> MAX7221 (blue)
- D12 <=> DIN (1)
- D11 <=> CLK (13
- D10 <=> LOAD (12)
|
|
Daisy chain first 7 segment display to second 7 segment display
|
|
MAX7221 <=> Rail
- ISET (18) 10k resistor <=> 5V rail (Controls brightness)
- GND (4) <=> GND rail
- GRD (9) <=> GND rail
- 5V (19) <=> 5V rail
|
|
MAX7221 <=> 7 segment display
- DIG0 (2) <=> Common cathode first 7 segment display
- DIG1 (11) <=> Common cathode second 7 segment display
- SEGA (14) <=> A
- SEGB (16) <=> B
- SEGC (20) <=> C
- SEGD (23) <=> D
- SEGE (21) <=> E
- SEGF (15) <=> F
- SEGG (17) <=> G
|
Code:
#include <LedControl.h>
LedControl lc = LedControl(12, 11, 10, 1); // datapin, clockpin, cs 1 = number of MAX7221 devices
unsigned long delaytime = 250;
void setup() {
lc.shutdown(0, false); // Wake up device 0
lc.setIntensity(0, 8); // Brightness (0–15) for device 0
lc.clearDisplay(0); // Clear display 0
}
void loop() {
for (int num = 0; num < 100; num++) {
int tens = num / 10; // Extract tens digit
int ones = num % 10; // Extract ones digit
lc.setDigit(0, 0, tens, false); // device 0 display 0
lc.setDigit(0, 1, ones, false); // device 0 display 1
delay(1000);
}
}
Ino file
Source and examples LedControl
|