/* 名称:单只数码管循环显示0~9
说明:主程序中的循环语句反复将0~9的段码送至P0口,使数字0~9循环显示
#include
#include
#define uchar unsigned char
#define uint unsigned int
uchar code DSY_CODE[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff};
//延时
void DelayMS(uint x)
uchar t;
while(x--) for(t=0;t<120;t++);
//主程序
void main()
uchar i=0;
P0=0x00;
while(1)
{ /* for(;i<11;i++){ P0=~DSY_CODE[i]; DelayMS(300);} //注:另一方案 */
P0=~DSY_CODE[i];
i=(i+1)%10;
DelayMS(300);
特别声明:以上内容(如有图片或视频亦包括在内)为自媒体平台“网易号”用户上传并发布,本平台仅提供信息存储服务。
Notice: The content above (including the pictures and videos if any) is uploaded and posted by a user of NetEase Hao, which is a social media platform and only provides information storage services.