基于51单片机心形流水灯C语言源程序Word下载.docx
《基于51单片机心形流水灯C语言源程序Word下载.docx》由会员分享,可在线阅读,更多相关《基于51单片机心形流水灯C语言源程序Word下载.docx(11页珍藏版)》请在冰豆网上搜索。
![基于51单片机心形流水灯C语言源程序Word下载.docx](https://file1.bdocx.com/fileroot1/2023-1/23/0a30a0e9-4137-4969-a245-efda238a1bce/0a30a0e9-4137-4969-a245-efda238a1bce1.gif)
voidOn_all()//开启所有灯
{
P0=0x00;
P1=0x00;
P2=0x00;
P3=0x00;
voidOff_all()//关闭所有灯
P0=0xff;
P1=0xff;
P2=0xff;
P3=0xff;
}
voidls()//正向流水灯
P0=0x00;
delayms(400);
P0=0x01;
delayms(50);
P0=0x02;
P0=0x04;
P0=0x08;
P0=0x10;
P0=0x20;
P0=0x40;
P0=0x80;
P2=0x01;
P2=0x02;
P2=0x04;
P2=0x08;
P2=0x10;
P2=0x20;
P2=0x40;
P2=0x80;
P3=0x80;
P3=0x40;
P3=0x20;
P3=0x10;
P3=0x08;
P3=0x04;
P3=0x02;
P3=0x01;
P1=0x80;
P1=0x40;
P1=0x20;
P1=0x10;
P1=0x08;
P1=0x04;
P1=0x02;
P1=0x01;
Off_all();
P0=0xfe;
P0=0xfd;
P0=0xfb;
P0=0xf7;
P0=0xef;
P0=0xdf;
P0=0xbf;
P0=0x7f;
P0=0xff;
P2=0xfe;
P2=0xfd;
P2=0xfb;
P2=0xf7;
P2=0xef;
P2=0xdf;
P2=0xbf;
P2=0x7f;
P3=0x7f;
P3=0xbf;
P3=0xdf;
P3=0xef;
P3=0xf7;
P3=0xfb;
P3=0xfd;
P3=0xfe;
P1=0x7f;
P1=0xbf;
P1=0xdf;
P1=0xef;
P1=0xf7;
P1=0xfb;
P1=0xfd;
P1=0xfe;
P0=0xfc;
P0=0xf8;
P0=0xf0;
P0=0xe0;
P0=0xc0;
P2=0xfc;
P2=0xf8;
P2=0xf0;
P2=0xe0;
P2=0xc0;
P3=0x3f;
P3=0x1f;
P3=0x0f;
P3=0x07;
P3=0x03;
P1=0x3f;
P1=0x1f;
P1=0x0f;
P1=0x07;
P1=0x03;
voidfan_ls()//反向流水灯
{
delayms(300);
On_all();
delayms(400);
delayms(50);
P1=0x04;
P1=0x20;
P1=0x80;
P1=0x00;
P3=0x01;
P3=0x10;
P2=0x80;
P1=0xfc;
P1=0xf8;
P1=0xf0;
P1=0xe0;
P1=0xc0;
P3=0xfc;
P3=0xf8;
P3=0xf0;
P3=0xe0;
P3=0xc0;
P2=0x3f;
P2=0x1f;
P2=0x0f;
P2=0x07;
P2=0x03;
P0=0x3f;
P0=0x1f;
P0=0x0f;
P0=0x07;
P0=0x03;
voidban_shan()//半边交替闪
P3=0x00;
P0=0xff;
P2=0xff;
P3=0xff;
P0=0x00;
P2=0x00;
voidshangxia_shan()//上下交替闪
P1=0x00;
P1=0xff;
voidhuayang_shan()//花样闪烁
delayms(200);
voidmain()
ls();
//正向流水
fan_ls();
//反向流水
ban_shan();
//半边交替闪
shangxia_shan();
//上下交替闪烁
huayang_shan();
//花样闪烁