// This version uses bit-banged SPI.
// If you see tearing (jagged edges on the circles) try the version
// which uses AVR's hardware SPI peripheral:
// https://wokwi.com/arduino/projects/318868939929027156
#define CLK1 9
#define DIN1 11
#define CS 10
#define CLK2 8
#define DIN2 12
byte background[16][8];
byte letter_A[8]={0b00000000,
0b00011000,
0b00100100,
0b10000001,
0b10000001,
0b11111111,
0b10000001,
0b10000001,
};
byte scren[16][8]={0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000,
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000,
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000,
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000,
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000,
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000,
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000,
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000,
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000,
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000,
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000,
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000,
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000,
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000,
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000,
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000
};
void shiftAll(byte send_to_address, byte send_this_data)
{
digitalWrite(CS, LOW);
for (int SEGMENTS = 0; SEGMENTS <8;SEGMENTS++) {
shiftOut(DIN1, CLK1, MSBFIRST, send_to_address);
shiftOut(DIN1, CLK1, MSBFIRST, send_this_data);
shiftOut(DIN2, CLK2, MSBFIRST, send_to_address);
shiftOut(DIN2, CLK2, MSBFIRST, send_this_data);
}
digitalWrite(CS, HIGH);
}
void display_scren(){
for (int segmen_width = 0; segmen_width<8;segmen_width++) {
digitalWrite(CS, LOW);
for (int segmen_length = 0; segmen_length<8;segmen_length++) {
int segmen_width2 =(segmen_width+8);
shiftOut(DIN1, CLK1, MSBFIRST,segmen_width+1);
shiftOut(DIN1, CLK1, LSBFIRST, scren[segmen_width][segmen_length]);
shiftOut(DIN2, CLK2, MSBFIRST,segmen_width+1);
shiftOut(DIN2, CLK2, LSBFIRST,scren[segmen_width2][segmen_length]);
}
digitalWrite(CS, HIGH);
}
}
void setup() {
Serial.begin(115200);
pinMode(CLK1, OUTPUT);
pinMode(DIN1, OUTPUT);
pinMode(CS, OUTPUT);
pinMode(CLK2, OUTPUT);
pinMode(DIN2, OUTPUT);
// Setup each MAX7219
shiftAll(0x0f, 0x00); //display test register - test mode off
shiftAll(0x0b, 0x07); //scan limit register - display digits 0 thru 7
shiftAll(0x0c, 0x01); //shutdown register - normal operation
shiftAll(0x0a, 0x0f); //intensity register - max brightness
shiftAll(0x09, 0x00); //decode mode register - No decode
//shiftAll(0x01, 0x01);
for(int i=0; i<8; i++){
for(int j=0; j<8; j++){
byte pixcel = bitRead(letter_A[i], j);
bitWrite(scren[i][1], j, pixcel);
}
}
}
void loop() {
display_scren();
}
void write_pixcel(int x, int y, byte pixcel){
bitWrite(scren[][], )
}