学习C51单片机——LED点阵屏显示爱心(学习笔记Keil5)
1、爱心代码
#include <REGX52.H>
sbit RCL = P3^5;
sbit SCK = P3^6;
sbit SER = P3^4;
void Delay(unsigned int xms)
{
unsigned char i, j;
while(xms--)
{
i = 2;
j = 239;
do
{
while (--j);
} while (--i);
}
}
void SendByte(unsigned char data1)
{
unsigned char a;
SCK = 1;
RCL = 1;
for(a=0;a<8;a++)
{
SER = data1 >> 7;
data1 <<= 1;
SCK = 0;
SCK = 1;
}
RCL = 0;
RCL = 1;
}
void main()
{
while(1)
{
P0 = 0xBF;
SendByte(0x30);
Delay(1);
SendByte(0x00);
P0 = 0xFF;
Delay(1);
P0 = 0xDF;
SendByte(0x48);
Delay(1);
SendByte(0x00);
P0 = 0xFF;
P0 = 0xEF;
SendByte(0x24);
Delay(1);
SendByte(0x00);
P0 = 0xFF;
P0 = 0xF7;
SendByte(0x24);
Delay(1);
SendByte(0x00);
P0 = 0xFF;
P0 = 0xFB;
SendByte(0x48);
Delay(1);
SendByte(0x00);
P0 = 0xFF;
P0 = 0xFD;
SendByte(0x30);
Delay(1);
SendByte(0x00);
P0 = 0xFF;
Delay(1);
}
}
2、实物图片展示
