
昨天完成的!
流水灯的代码:
#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;
}
}
打赏帖 | |
---|---|
汽车电子中巡航控制系统的使用被打赏10分 | |
分享汽车电子中巡航控制系统知识被打赏10分 | |
分享安全气囊系统的检修注意事项被打赏10分 | |
分享电子控制安全气囊计算机知识点被打赏10分 | |
【分享开发笔记,赚取电动螺丝刀】【OZONE】使用方法总结被打赏20分 | |
【分享开发笔记,赚取电动螺丝刀】【S32K314】芯片启动流程分析被打赏40分 | |
【分享开发笔记,赚取电动螺丝刀】【S32K146】S32DS RTD 驱动环境搭建被打赏12分 | |
【分享开发笔记,赚取电动螺丝刀】【IAR】libc标注库time相关库函数使用被打赏23分 | |
LP‑MSPM0L1306开发版试用结果被打赏10分 | |
【分享开发笔记,赚取电动螺丝刀】【LP-MSPM0L1306】适配 RT-Thread Nano被打赏23分 |