
昨天完成的!
流水灯的代码:
#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;
}
}
打赏帖 | |
---|---|
宏定义和const关键字定义被打赏5分 | |
【功率监测与控制系统DIY活动成果贴】DIY功率计与LabVIEW数据采集被打赏100分 | |
【Freertos】任务管理被打赏10分 | |
分享博世的两种不同的喷射系统模式被打赏5分 | |
汽车+开路实验与短路实验被打赏10分 | |
多点式电子控制汽油喷射系统知识分享被打赏10分 | |
分享机械控制式汽油喷射系统被打赏5分 | |
【分享开发笔记,赚取电动螺丝刀】解决基于CH341制作无线模块时芯片发热问题被打赏31分 | |
【分享开发笔记,赚取电动螺丝刀】使用STM32F103ZE主控调试RS485通讯的避坑经验被打赏36分 | |
【分享开发笔记,赚取电动螺丝刀】移植xprintf模块被打赏27分 |