51单片机8X8点阵屏显示
显示一个爱心
#include <reg52.h>
#include <intrins.h>
sbit DIO = P3^4;//串行数据口
sbit S_CLK = P3^5;//移位寄存器时钟
sbit R_CLK = P3^6;//输出锁存器时钟
unsigned char code table[8]={
0xFF,0xEF,0xD7,0xBB,0x7D,0x6D,0x93,0xFF}; //♥
void send(unsigned char dat)
{
unsigned char i;
S_CLK = 0;
R_CLK = 0;
for(i=0; i<8; i++)
{
if(dat & 0x01)
DIO = 1;
else
DIO = 0;
S_CLK = 1;
dat >>= 1;
S_CLK = 0;
}
}
void main()
{
unsigned char j,row;
while(1)
{
row = 0x80;
for(j=0; j<8; j++)
{
send(table[j]);
send(row);
R_CLK = 1;
R_CLK = 0;
row = _cror_(row,1);
}
}
}