void SPI_INIT()
{
volatile char *dir_b,*outB,*spcr; // initialization of portb and control register
dir_b=0x24;// address of data direction port B
outB=0x25; // Address of output port B
spcr=0x4c; // Address of control register
*dir_b=0x07; // output mode - DIN, SCK
*outB=0x01; // SS= 1;
*spcr=0x51;
}
void SPI_TRANSMIT(char ch)
{
volatile char *spdr,*spsr;
spsr=0x4d;
*spsr=0x00;
spdr=0x4e;
*spdr=ch;
while(!*spsr);
delay(5);
}
void setup() {
// put your setup code here, to run once:
SPI_INIT();
}
void loop()
{
volatile char Row_select=0x01,k=0,f=0,l=0;
volatile char Column_select[]=
{
0b11000011,
0b11000011,
0b11000011,
0b11000011,
0b11011011,
0b11111111,
0b11100111,
0b11000011, // W
// aabbb jjjjjjjjjjjjjjjjjjjjjjjjjjj
0b00000000,
0b00000000,
0b00000000,
0b00111100,
0b01100110,
0b01111110,
0b00000110,
0b00111100, // e
0b00000110,
0b00000110,
0b00000110,
0b00000110,
0b00000110,
0b00000110,
0b00000110,
0b00001100, // l
0b00000000,
0b00000000,
0b00000000,
0b00111100,
0b00110110,
0b00000110,
0b00000110,
0b00111100,
// c
0b00000000,
0b00000000,
0b00000000,
0b00111100,
0b01100110,
0b01100110,
0b01100110,
0b00111100,
// o
0b00000000,
0b00000000,
0b01101110,
0b11011011,
0b11011011,
0b11011011,
0b11011011,
0b11011011,
// m
0b00000000,
0b00000000,
0b00000000,
0b00111100,
0b01100110,
0b01111110,
0b00000110,
0b00111100, // e
};
volatile char *dir_b,*outB;
dir_b=0x24;
outB=0x25;
*dir_b=0x01;
while(1)
{
f=0;
Row_select=0x01;
for(k=0;k<7;k++)
{
l=0;
while(l<20)
{
Row_select=0x01;
for(int i=f;i<f+8;i++)
{
*outB=0x00;
SPI_TRANSMIT(Row_select++);
SPI_TRANSMIT(Column_select[i]);
*outB=0x01;
}
l++;
}
f=f+8;
}
}
}