急!!!求单只数码管循环显示0~9的代码解释,数码管是共阳极的。万分感谢!!!

代码如下:#include<reg51.h>#include<intrins.h>#defineucharunsignedchar#defineuintunsignedi... 代码如下:

#include<reg51.h>
#include<intrins.h>
#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)
{
P0=~DSY_CODE[i];
i=(i+1)%10;
DelayMS(300);
}
}
展开
 我来答
wmgi7205
2012-11-01 · TA获得超过388个赞
知道小有建树答主
回答量:771
采纳率:66%
帮助的人:443万
展开全部
#include<reg51.h>//单片机寄存器相关的文件
#include<intrins.h>//具有空指令的文件
#define uchar unsigned char//宏定义 以后用uchar替代unsigned char
#define uint unsigned int //宏定义作用同上
uchar code DSY_CODE[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff};//数码管0-9的段码值
//延时
void DelayMS(uint x)//延时函数
{
uchar t;//定义变量数值范围0-255
while(x--) for(t=0;t<120;t++);
}
//主程序
void main() //主函数
{
uchar i=0; //定义变量i 并且i=0
P0=0x00; //P0口=0x00 P0口全部为低电平
while(1) //主循环
{
P0=~DSY_CODE[i];//P0=取反的数码管段码值
i=(i+1)%10; //i =i自加1 个位的数
DelayMS(300); //延时
}
}
黑胡椒叫牛排
2018-04-18
知道答主
回答量:2
采纳率:0%
帮助的人:1772
展开全部

这是对的 嗯

已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式