真正的黑子
#include <REGX52.H>
void Delay(unsigned int xms);
void _74HC595_WriteByte(unsigned char byte);
void LED(unsigned char Y,DATA);
void LED_Init();
sbit RCK=P3^5; //RCLK
sbit SCK=P3^6; //SRCL
sbit SER=P3^4; //SER
//坤坤矩阵
unsigned char code DH[]=
{
0x00,0x0E,0x1B,0x7F,0x7F,0x1B,0x0E,0x00,
0x00,0x04,0x0C,0x18,0x7F,0x7F,0x1B,0x0E,
0x00,0x08,0x0C,0x05,0x7F,0x7F,0x1E,0x0C,
0xC0,0x00,0x41,0x22,0x1A,0x7C,0x7D,0x1A,
0x00,0x60,0x61,0x12,0x0A,0x7E,0x7F,0x08,
0x00,0x06,0x0E,0x08,0x0B,0x3E,0x3E,0x0B,
0x00,0x03,0x0B,0x08,0x0B,0x3E,0x3E,0x0B,
0x00,0x06,0x0E,0x08,0x09,0x3F,0x3E,0x0B,
0x00,0x0E,0x13,0x7E,0x7E,0x1F,0x0E,0x00,
0x08,0x13,0x7E,0x7E,0x12,0x1D,0x0C,0x00,
0x09,0x12,0x7E,0x7F,0x10,0x13,0x03,0x00,
0x09,0x12,0x7E,0x7F,0x10,0x1C,0x0C,0x00,
0x00,0x0C,0x15,0x7E,0x7E,0x17,0x0E,0x00,
0x00,0x30,0x38,0x0D,0x7E,0x7F,0x1D,0x08,
0xC0,0xC0,0x30,0x1B,0x7C,0x7F,0x08,0x00,
0x00,0x00,0x37,0xF8,0xFA,0x34,0x00,0x00,
0x00,0x00,0x1B,0x7C,0x7C,0x1A,0x01,0x00,
0x00,0x00,0x09,0x1E,0x7C,0x7F,0x18,0x00,
0x00,0x00,0x1B,0x7C,0x7C,0x1B,0x00,0x00,
0x00,0x00,0x09,0x1E,0x7C,0x7F,0x18,0x00,
0x00,0x00,0x1B,0x7C,0x7C,0x1B,0x00,0x00,
0x08,0x10,0x16,0x7C,0x7F,0x10,0x08,0x00,
0x00,0x10,0x13,0x7C,0x7E,0x18,0x00,0x00,
0x00,0x08,0x13,0x7C,0x7F,0x10,0x10,0x00,
0x00,0x08,0x12,0xFC,0xFD,0x3A,0x00,0x00,
0x00,0x08,0x12,0xFC,0xFC,0x22,0x10,0x00,
0x00,0x00,0x61,0x12,0x7C,0x7F,0x10,0x60,
0x00,0x00,0x20,0x11,0x12,0x7C,0x7E,0x19,
0x00,0x00,0x00,0x31,0x0A,0x7C,0x7E,0x0D,
0x00,0x00,0x20,0x11,0x12,0x7C,0x7E,0x19,
0x00,0x00,0x00,0x31,0x0A,0x7C,0x7E,0x0D,
0x00,0x00,0x20,0x11,0x12,0x7C,0x7E,0x19,
0x00,0x00,0x00,0x31,0x0A,0x7C,0x7E,0x0D,
0x00,0x00,0x20,0x11,0x12,0x7C,0x7E,0x19,
0x00,0x00,0x00,0x31,0x0A,0x7C,0x7E,0x0D,
};
void main()
{
unsigned char i,py=0,pl=0;
LED_Init();
while(1)
{
for(i=0;i<8;i++)
{
LED(i,DH[i+py]);
}
pl++;
if(pl>25)
{
pl=0;
py+=8;
if(py>10000)
{
py=0;
}
}
}
}
//延时xms
void Delay(unsigned int xms)
{
while(xms--)
{
unsigned char i, j;
i = 2;
j = 199;
do
{
while (--j);
} while (--i);
}
}
void _74HC595_WriteByte(unsigned char byte)
{
unsigned char i;
for(i=0;i<8;i++)
{
SER=byte&(0x80>>i);
SCK=1;
SCK=0;
}
RCK=1;
RCK=0;
}
//led设置参数
void LED(unsigned char Y,DATA)
{
_74HC595_WriteByte(DATA);
P0=~(0X80>>Y);
Delay(1);
P0=0XFF;
}
//led初始化
void LED_Init()
{
SCK=0;
RCK=0;
}
代码效果
文章来源地址https://www.toymoban.com/news/detail-743340.html
文章来源:https://www.toymoban.com/news/detail-743340.html
到了这里,关于51单片机 点阵矩阵 坤坤代码的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!