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,z=0;
volatile short Column_select[]=
{
0b0110000110000000,
0b0110000110000000,
0b0110000110000000,
0b0110000110000000,
0b0110110110000000,
0b0111111110000000,
0b0111001110000000,
0b0110000110000000, // W
0b0000000000000000,
0b0000000000000000,
0b0000000000000000,
0b0011110000000000,
0b0110011000000000,
0b0111111000000000,
0b0000011000000000,
0b0011110000000000, // e
0b0000011000000000,
0b0000011000000000,
0b0000011000000000,
0b0000011000000000,
0b0000011000000000,
0b0000011000000000,
0b0000011000000000,
0b0000110000000000, // l
0b0000000000000000,
0b0000000000000000,
0b0000000000000000,
0b0011110000000000,
0b0011011000000000,
0b0000011000000000,
0b0000011000000000,
0b0011110000000000,
// c
0b0000000000000000,
0b0000000000000000,
0b0000000000000000,
0b0011110000000000,
0b0110011000000000,
0b0110011000000000,
0b0110011000000000,
0b0011110000000000,
// o
0b0000000000000000,
0b0000000000000000,
0b0111011110000000,
0b0110110110000000,
0b0110110110000000,
0b0110110110000000,
0b0110110110000000,
0b0110110110000000,
// m
0b0000000000000000,
0b0000000000000000,
0b0000000000000000,
0b0011110000000000,
0b0110011000000000,
0b0111111000000000,
0b0000011000000000,
0b0011110000000000, // e
};
volatile char *dir_b,*outB;
dir_b=0x24;
outB=0x25;
*dir_b=0x01;
while(1)
{
f=0;
for(k=0;k<7;k++)
{
for(int j=0;j<16;j++)
{
Row_select=0x01;
for(int i=f;i<f+8;i++)
{
*outB=0x00;
SPI_TRANSMIT(Row_select++);
SPI_TRANSMIT(Column_select[i]>>j);
*outB=0x01;
}
}
f=f+8;
}
}
}