c语言降序程序注释,C语言小白 有些程序读不懂 有没有大佬可以注释一下 感谢!...

#include

#define XBYTE ((unsigned char volatile xdata *) 0)

#define adin XBYTE[0x7fff] //P2=0x7f P0 = 0xff

#define addo (5.0/255.0)

#define zero 0.005

sbit  LED1 = P3^0

sbit  LED2 = P3^1;

sbit  LED3 = P3^2;

sbit  LED4 = P3^3;

sbit  dp   = P3^5;

static unsigned char dispdata[4];

unsigned char code num[] = { 0x3f,0x06,0x5b,0x4f,0x66,0x6d,  0x7d,0x07,0x7f,0x6f,0x77,0x3e }

void delayus(unsigned int us)

{

while(us--);

}

unsigned char ad_action(unsigned char chn)

{

unsigned char read_data;

adin = chn

delayus(6);

read_data = adin;

return read_data

}

//êyÖμ′|àí

void decodenum(float adv,unsigned char chn

{

unsigned int temp;

temp = (unsigned int)(adv*100);

dispdata[0] = temp/100;

dispdata[1] = temp/10%10;

dispdata[2] = temp%10;

dispdata[3] = chn;

}

void  dispone(unsigned char LED,bit ifpoint,unsigned char number)   //number 0--9

{

switch(LED)

{

case 0:LED1 = 0;break;

case 1:LED2 = 0;break;

case 2:LED3 = 0;break;

case 3:LED4 = 0;break;

default: P3 = 0xff;

}

if( ifpoint == 1 ) dp = 1;

else dp = 0;

P2 = num[number]|0x80

delayus(200);

P3 = 0xff;

}

void disp()

{

unsigned char i;

bit point;

for(i = 0;i<4;i++)

{

if(i == 1) point = 0

else point = 1;

dispone(i,point,dispdata[i]);

}

}

void main()

{

unsigned int cnt = 0

while(1)

{

switch(cnt++)

{

case 0  : decodenum(ad_action(0)*addo+zero,0);break

case 70 : decodenum(ad_action(1)*addo+zero,1);break

case 140: decodenum(ad_action(2)*addo+zero,2);break

case 210: decodenum(ad_action(3)*addo+zero,3);break

case 280: decodenum(ad_action(4)*addo+zero,4);break

case 350: decodenum(ad_action(5)*addo+zero,5);break

case 420: decodenum(ad_action(6)*addo+zero,6);break

case 490: decodenum(ad_action(7)*addo+zero,7);break;

case 560: cnt = 0;break;

}

disp();

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值