流水灯的代码:
#include<reg51.h>
void delay(unsigned int cnt) //延时
{
while(cnt--);
}
main()
{
P1=0xfe;
while(1)
{
delay(30000);
P1=P1<<1;
P1=P1|0x01;
if(P1==0x7f)
{
delay(30000);
P1=0xfe;
}
}
}
先上代码,暂时不知道怎么上传视频。
#include<reg51.h> //双色点阵显示心形
unsigned char const dofly[]={0x00,0x6C,0x92,0x82,0x44,0x28,0x10,0x00};
unsigned char code seg[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
void delay(unsigned int cnt)
{
while(--cnt);
}
main()
{
unsigned char i;
while(1)
{
P0=dofly[i];
P2=seg[i];
delay(300);
i++;
if(8==i)
i=0;
}
}
#include<reg51.h> //数码管显示
unsigned char const dofly[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
// 显示值 01234567
unsigned char code seg[]={0,1,2,3,4,5,6,7};
void delay(unsigned int cnt)
{
while(--cnt);
}
main()
{
unsigned char i;
while(1)
{
P0=dofly[i];
P2=seg[i];
delay(200);
i++;
if(8==i)
i=0;
}
}
回复
有奖活动 | |
---|---|
【有奖活动——B站互动赢积分】活动开启啦! | |
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |