Good morning community, I am making a 70 led matrix display (7 rows and 10 columns) for a personal project of a smart parking lot with an access control system. In the led matrix I will display messages like "Welcome to...", "Thank you for coming to...", "Incorrect user or password", etc.
To manage the 10 columns I use two 74HC595 shift registers connected in cascade.
To control the 7 rows I use a CD4017BE which will scan the rows quickly from top to bottom. The 8 rows of the LED array are independently connected to a 2N3904 NPN transistor which provide a ground path to sink the combined current of all the LEDs in a row.
I have much of the code done, the section that is causing me difficulty is the programming logic of multiplexing the leds using the shift register. What data do I need to send to the shiftOut function so that my led matrix will shift the characters in the string from right to left? I appreciate your help, thank you.
Thanks for your help, thanks.
Components used:
- 1 PCB 10x10 (Main Board)
- 1 PCB 10x5 (Matrix led)
- 40 Pin header
- 1 28-pin socket
- 2 16-pin sockets
- 1 terminal block
- 1 push button
- 1 ATMEGA328p
- 1 CD4017BE
- 2 74HC595
- 1 16 MHz crystal
- 2 Ceramic capacitors 22 pF
- 1 7805
- 1 Capacitor 0.22 uF
- 1 Capacitor 100 uF
- 1 Diode 1N4147
- 1 Slide switch
- 1 Led 5 mm
- 7 NPN 2N3904 transistors
- 1 Resistor 220Ω
- 13 Resistors 10kΩ
- 10 Resistors 150Ω
- 70 Leds 3 mm
Control circuit:
LED matrix circuit:
Code:
const byte char_data[95][7]={
{0, 0, 0, 0, 0, 0, 0}, // space
{0b100, 0b100, 0b100, 0b100, 0b100, 0, 0b100}, // !
{0b1010, 0b1010, 0b1010, 0, 0, 0, 0}, // "
{0b1010, 0b1010, 0b11111, 0b1010, 0b11111, 0b1010, 0b1010}, // #
{0b100, 0b1111, 0b10100, 0b1110, 0b101, 0b11110, 0b100}, // $
{0b11000, 0b11001, 0b10, 0b100, 0b1000, 0b10011, 0b11}, // %
{0b1000, 0b10100, 0b10100, 0b1000, 0b10101, 0b10010, 0b1101}, // &
{0b100, 0b100, 0b100, 0, 0, 0, 0}, // '
{0b100, 0b1000, 0b10000, 0b10000, 0b10000, 0b1000, 0b100}, // (
{0b100, 0b10, 0b1, 0b1, 0b1, 0b10, 0b100}, // )
{0b100, 0b10101, 0b1110, 0b100, 0b1110, 0b10101, 0b100}, // *
{0, 0b100, 0b100, 0b11111, 0b100, 0b100, 0}, // +
{0, 0, 0, 0, 0b100, 0b100, 0b1000}, // ,
{0, 0, 0, 0b11111, 0, 0, 0}, // -
{0, 0, 0, 0, 0, 0, 0b100}, // .
{0, 0b1, 0b10, 0b100, 0b1000, 0b10000, 0}, // /
{0b1110, 0b10001, 0b10011, 0b10101, 0b11001, 0b10001, 0b1110}, // 0
{0b110, 0b1100, 0b100, 0b100, 0b100, 0b100, 0b1110}, // 1
{0b1110, 0b10001, 0b1, 0b110, 0b1000, 0b10000, 0b11111}, // 2
{0b11111, 0b1, 0b10, 0b110, 0b1, 0b10001, 0b1111}, // 3
{0b10, 0b110, 0b1010, 0b10010, 0b11111, 0b10, 0b10}, // 4
{0b11111, 0b10000, 0b11110, 0b1, 0b1, 0b10001, 0b1110}, // 5
{0b01110, 0b10001, 0b10000, 0b11110, 0b10001, 0b10001, 0b1110}, // 6
{0b11111, 0b1, 0b10, 0b100, 0b1000, 0b1000, 0b1000}, // 7
{0b01110, 0b10001, 0b10001, 0b1110, 0b10001, 0b10001, 0b1110}, // 8
{0b01110, 0b10001, 0b10001, 0b1111, 0b1, 0b10001, 0b1110}, // 9
{0, 0, 0b100, 0, 0b100, 0, 0}, // :
{0, 0, 0b100, 0, 0b100, 0b100, 0b1000}, // ;
{0b10, 0b100, 0b1000, 0b10000, 0b1000, 0b100, 0b10}, // <
{0, 0, 0b11111, 0, 0b11111, 0, 0}, // =
{0b1000, 0b100, 0b10, 0b1, 0b10, 0b100, 0b1000}, // >
{0b1110, 0b10001, 0b1, 0b10, 0b100, 0, 0b100}, // ?
{0b1110, 0b10001, 0b10111, 0b10101, 0b10110, 0b10000, 0b1111}, // @
{0b1110, 0b10001, 0b10001, 0b11111, 0b10001, 0b10001, 0b10001}, // A
{0b11110, 0b10001, 0b10001, 0b11110, 0b10001, 0b10001, 0b11110}, // B
{0b1110, 0b10001, 0b10000, 0b10000, 0b10000, 0b10001, 0b1110}, // C
{0b11110, 0b10001, 0b10001, 0b10001, 0b10001, 0b10001, 0b11110}, // D
{0b11111, 0b10000, 0b10000, 0b11110, 0b10000, 0b10000, 0b11111}, // E
{0b11111, 0b10000, 0b10000, 0b11110, 0b10000, 0b10000, 0b10000}, // F
{0b1110, 0b10001, 0b10000, 0b10111, 0b10101, 0b10001, 0b1110}, // G
{0b10001, 0b10001, 0b10001, 0b11111, 0b10001, 0b10001, 0b10001}, // H
{0b11111, 0b100, 0b100, 0b100, 0b100, 0b100, 0b11111}, // I
{0b1, 0b1, 0b1, 0b1, 0b1, 0b10001, 0b1110}, // J
{0b10001, 0b10001, 0b10010, 0b11100, 0b10010, 0b10001, 0b10001}, // K
{0b10000, 0b10000, 0b10000, 0b10000, 0b10000, 0b10000, 0b11111}, // L
{0b10001, 0b11011, 0b10101, 0b10101, 0b10001, 0b10001, 0b10001}, // M
{0b10001, 0b10001, 0b11001, 0b10101, 0b10011, 0b10001, 0b10001}, // N
{0b1110, 0b10001, 0b10001, 0b10001, 0b10001, 0b10001, 0b1110}, // O
{0b11110, 0b10001, 0b10001, 0b11110, 0b10000, 0b10000, 0b10000}, // P
{0b1110, 0b10001, 0b10001, 0b10001, 0b10101, 0b10011, 0b1111}, // Q
{0b11110, 0b10001, 0b10001, 0b11110, 0b10001, 0b10001, 0b10001}, // R
{0b1111, 0b10000, 0b10000, 0b1110, 0b1, 0b1, 0b11110}, // S
{0b11111, 0b100, 0b100, 0b100, 0b100, 0b100, 0b100}, // T
{0b10001, 0b10001, 0b10001, 0b10001, 0b10001, 0b10001, 0b1110}, // U
{0b10001, 0b10001, 0b10001, 0b10001, 0b10001, 0b1010, 0b100}, // V
{0b10001, 0b10001, 0b10001, 0b10101, 0b10101, 0b11011, 0b10001}, // W
{0b10001, 0b10001, 0b1010, 0b100, 0b1010, 0b10001, 0b10001}, // X
{0b10001, 0b10001, 0b1010, 0b100, 0b100, 0b100, 0b100}, // Y
{0b11111, 0b1, 0b10, 0b100, 0b1000, 0b10000, 0b11111}, // Z
{0b1110, 0b1000, 0b1000, 0b1000, 0b1000, 0b1000, 0b1110}, // [
{0, 0b10000, 0b1000, 0b100, 0b10, 0b1, 0}, // backward slash
{0b1110, 0b10, 0b10, 0b10, 0b10, 0b10, 0b1110}, // ]
{0, 0, 0b100, 0b1010, 0b10001, 0, 0}, // ^
{0, 0, 0, 0, 0, 0, 0b11111}, // _
{0b1000, 0b100, 0b10, 0, 0, 0, 0}, // `
{0, 0, 0b1110, 0b1, 0b1111, 0b10001, 0b1111}, // a
{0b10000, 0b10000, 0b10000, 0b11110, 0b10001, 0b10001, 0b11110}, // b
{0, 0, 0b1110, 0b10001, 0b10000, 0b10001, 0b1110}, // c
{0b1, 0b1, 0b1, 0b1111, 0b10001, 0b10001, 0b1111}, // d
{0, 0, 0b1110, 0b10001, 0b11111, 0b10000, 0b1111}, // e
{0b1110, 0b1001, 0b11100, 0b1000, 0b1000, 0b1000, 0b1000}, // f
{0, 0, 0b1110, 0b10001, 0b1111, 0b1, 0b1110}, // g
{0b10000, 0b10000, 0b10000, 0b11110, 0b10001, 0b10001, 0b10001}, // h
{0b100, 0, 0b100, 0b100, 0b100, 0b100, 0b1110}, // i
{0b1, 0, 0b11, 0b1, 0b1, 0b10001, 0b1110}, // j
{0b10000, 0b10000, 0b10001, 0b10010, 0b11100, 0b10010, 0b10001}, // k
{0b1100, 0b100, 0b100, 0b100, 0b100, 0b100, 0b1110}, // l
{0, 0, 0b11110, 0b10101, 0b10101, 0b10101, 0b10101}, // m
{0, 0, 0b11110, 0b10001, 0b10001, 0b10001, 0b10001}, // n
{0, 0, 0b1110, 0b10001, 0b10001, 0b10001, 0b1110}, // o
{0, 0, 0b1111, 0b1001, 0b1110, 0b1000, 0b1000}, // p
{0, 0, 0b1111, 0b10001, 0b1111, 0b1, 0b1}, // q
{0, 0, 0b10111, 0b11000, 0b10000, 0b10000, 0b10000}, // r
{0, 0, 0b1111, 0b10000, 0b1110, 0b1, 0b11110}, // s
{0b100, 0b100, 0b1110, 0b100, 0b100, 0b100, 0b11}, // t
{0, 0, 0b10001, 0b10001, 0b10001, 0b10011, 0b1101}, // u
{0, 0, 0b10001, 0b10001, 0b10001, 0b1010, 0b100}, // v
{0, 0, 0b10001, 0b10001, 0b10101, 0b11111, 0b10101}, // w
{0, 0, 0b10001, 0b1010, 0b100, 0b1010, 0b10001}, // x
{0, 0, 0b10001, 0b10001, 0b1111, 0b1, 0b11110}, // y
{0, 0, 0b11111, 0b10, 0b100, 0b1000, 0b11111}, // z
{0b10, 0b100, 0b100, 0b1000, 0b100, 0b100, 0b10}, // {
{0b100, 0b100, 0b100, 0b100, 0b100, 0b100, 0b100}, // |
{0b1000, 0b100, 0b100, 0b10, 0b100, 0b100, 0b1000}, // }
{0, 0, 0, 0b1010, 0b10101, 0, 0} // ~
};
char message[] = "abc";
void setup(){
// PORTB as output.
// Pin 13: ClockRegister
// Pin 12: Latch
// Pin 11: Data
// Pin 10: Reset
// Pin 9: Clock4017
DDRB = 0b111111;
// Makes sure the 4017 value is 0.
PORTB = 0b100;
PORTB = 0;
}
void send_data(unsigned int data){
byte mask = 0b1, flag = 0;
for (byte i=0; i<10; i++){
flag = data & mask;
if (flag) digitalWrite(11, HIGH);
else digitalWrite(11, LOW);
digitalWrite(13, HIGH);
digitalWrite(13, LOW);
mask <<= 1;
}
digitalWrite(12, HIGH);
digitalWrite(12, LOW);
}
void loop(){
for (byte i=0; i<7; i++){
send_data(0b10001111);
delay(1000);
digitalWrite(9, HIGH);
digitalWrite(9, LOW);
}
digitalWrite(10, HIGH);
digitalWrite(10, LOW);
}


