Hello guys,
I need to do a project for school and I want to do a 8x16 matrix.
I have built two 8x8 matrix. Each is controlled by two 74HC595 Shiftregister. One for the rows and one for the columns.
It works fine, but it costs a lot of time to change the text. I have to copy the binary code of each letter of the text in an array.
Now I want to optimize the programm that I just need to write the text in a string or something like that.
// A 0b11111000,0b11111100,0b00100110,0b00100110,0b11111100,0b11111000,0b00000000,0b00000000,
// B 0b10000010,0b11111110,0b11111110,0b10010010,0b10010010,0b11111110,0b01101100,0b00000000,0b00000000,
// C 0b01111100,0b11111110,0b10000010,0b10000010,0b11000110,0b01000100,0b00000000,0b00000000,
// D 0b10000010,0b11111110,0b11111110,0b10000010,0b11000110,0b01111100,0b00111000,0b00000000,0b00000000,
// E 0b10000010,0b11111110,0b11111110,0b10010010,0b10111010,0b10000010,0b11000110,0b00000000,0b00000000,
// F 0b10000010,0b11111110,0b11111110,0b10010010,0b00111010,0b00000010,0b00000110,0b00000000,0b00000000,
// G 0b00111000,0b01111100,0b11000110,0b10000010,0b10100010,0b11100110,0b11100100,0b00000000,0b00000000,
// H 0b11111110,0b11111110,0b00010000,0b00010000,0b11111110,0b11111110,0b00000000,0b00000000,
// I 0b10000010,0b11111110,0b11111110,0b10000010,0b00000000,0b00000000,
// J 0b01100000,0b11100000,0b10000000,0b10000010,0b11111110,0b01111110,0b00000010,0b00000000,0b00000000,
// K 0b10000010,0b11111110,0b11111110,0b00010000,0b00111000,0b11101110,0b11000110,0b00000000,0b00000000,
// L 0b10000010,0b11111110,0b11111110,0b10000010,0b10000000,0b11000000,0b11100000,0b00000000,0b00000000,
// M 0b11111110,0b11111110,0b00001100,0b00011000,0b00001100,0b11111110,0b11111110,0b00000000,0b00000000,
// N 0b11111110,0b11111110,0b00001100,0b00011000,0b00110000,0b11111110,0b11111110,0b00000000,0b00000000,
// O 0b00111000,0b01111100,0b11000110,0b10000010,0b11000110,0b01111100,0b00111000,0b00000000,0b00000000,
// P 0b10000010,0b11111110,0b11111110,0b10010010,0b00010010,0b00011110,0b00001100,0b00000000,0b00000000,
// Q 0b00111100,0b01111110,0b01000010,0b11100010,0b11111110,0b10111100,0b00000000,0b00000000,
// R 0b10000010,0b11111110,0b11111110,0b00010010,0b00110010,0b11111110,0b11001100,0b00000000,0b00000000,
// S 0b01001100,0b11011110,0b10011010,0b10110010,0b11100110,0b01100100,0b00000000,0b00000000,
// T 0b00000110,0b10000010,0b11111110,0b11111110,0b10000010,0b00000110,0b00000000,0b00000000,
// U 0b11111110,0b11111110,0b10000000,0b10000000,0b11111110,0b11111110,0b00000000,0b00000000,
// V 0b00111110,0b01111110,0b11000000,0b11000000,0b01111110,0b00111110,0b00000000,0b00000000,
// W 0b11111110,0b11111110,0b01100000,0b00110000,0b01100000,0b11111110,0b11111110,0b00000000,0b00000000,
// X 0b10000110,0b11001110,0b01111000,0b00110000,0b01111000,0b11001110,0b10000110,0b00000000,0b00000000,
// Y 0b00001110,0b10011110,0b11110000,0b11110000,0b10011110,0b00001110,0b00000000,0b00000000,
// Z 0b10001110,0b11000110,0b11100010,0b10110010,0b10011010,0b11001110,0b11100110,0b00000000,0b00000000,
// SPACE_GROß 0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,
// SPACE_KLEIN 0b00000000,0b00000000,0b00000000,0b00000000,
//, 0b10000000,0b01000000,0b00000000,0b00000000,
//. 0b11000000,0b11000000,0b00000000,0b00000000
//? 0b00001100,0b00000010,0b10110010,0b00010010,0b00001100,0b00000000,0b00000000,
//! 0b10111110,0b00000000,0b00000000,
//- 0b00010000,0b00010000,0b00010000,0b00000000,0b00000000,
const int latchPin = A8; //Pin connected to ST_CP of 74HC595
const int clockPin = A12; //Pin connected to SH_CP of 74HC595
const int dataPin = A11; //Pin connected to DS of 74HC595
const int latchPin2 = A2; //Pin connected to ST_CP of 74HC595
const int clockPin2 = A3; //Pin connected to SH_CP of 74HC595
const int dataPin2 = A0; //Pin connected to DS of 74HC595
int data[] = {
0b11111110,0b11111110,0b00010000,0b00010000,0b11111110,0b11111110,0b00000000,0b00000000, //H
0b10000010,0b11111110,0b11111110,0b10010010,0b10111010,0b10000010,0b11000110,0b00000000,0b00000000, //E
0b10000010,0b11111110,0b11111110,0b10000010,0b10000000,0b11000000,0b11100000,0b00000000,0b00000000, //L
0b10000010,0b11111110,0b11111110,0b10000010,0b10000000,0b11000000,0b11100000,0b00000000,0b00000000, //L
0b00111000,0b01111100,0b11000110,0b10000010,0b11000110,0b01111100,0b00111000,0b00000000,0b00000000, //O
};
void setup ()
{
pinMode(latchPin,OUTPUT);
pinMode(clockPin,OUTPUT);
pinMode(dataPin,OUTPUT);
pinMode(latchPin2,OUTPUT);
pinMode(clockPin2,OUTPUT);
pinMode(dataPin2,OUTPUT);
digitalWrite(latchPin, LOW);
digitalWrite(clockPin, LOW);
digitalWrite(dataPin, LOW);
digitalWrite(latchPin2, LOW);
digitalWrite(clockPin2, LOW);
digitalWrite(dataPin2, LOW);
};
void loop()
{
for(int n=0; n<44; n++)
{
for(int t=0; t<7; t++)
{
int dat = 1;
for(int num = n; num < 8+n ; num++)
{
shiftOut(dataPin,clockPin,MSBFIRST, data[num]);
shiftOut(dataPin2,clockPin2, MSBFIRST, data[num-8]);
shiftOut(dataPin,clockPin,MSBFIRST,~dat);
shiftOut(dataPin2,clockPin2,MSBFIRST,~dat);
digitalWrite(latchPin,HIGH);
digitalWrite(latchPin2,HIGH);
digitalWrite(latchPin,LOW);
digitalWrite(latchPin2,LOW);
dat = dat<< 1;
delay(1);
}
}
}
}
I guess it´s not the best solution for the matrix with four shiftregister and this code.
I just need held for that textfield. So you can just write the text in a field and the programm will automaticly take the right bytes for the data[].
I´m thankfull for any help!