c语言while跳不出来,单片机C语言while循环为假,为什么一直跳不出去(就是松手确定那里)...

#include "reg52.h"                         //此文件中定义了单片机的一些特殊功能寄存器

typedef unsigned int u16;          //对数据类型进行声明定义

typedef unsigned char u8;

char num;

char  temp;

u8 code smgduan[17]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,

0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};//显示0~F的值

u8 keyvalue;

void delay(u16 i)

{

while(i--);

}

void main()

{         num=0;          P2=0;

while(1)

{

P1=0xfe;

temp=P1;

temp=temp&0xf0;

while(temp!=0xf0)

{

delay(500);

temp=P1; //

temp= temp&0xf0;

while(temp!=0xf0)

{           temp=P1;         //此句非常重要

switch(temp)

{

case 0xee : num=1;

break;

case 0xde : num=2;

break;

case 0xbe : num=3;

break;

case 0x7e : num=4;

break;

}

while( temp!=0xf0) //松手确定

{

temp=P1;

temp=temp&0xf0;

}

P0=0;

P2=smgduan[num];

}

}

P1=0xfd;

temp=P1;

temp=temp&0xf0;

while(temp!=0xf0)

{

delay(500);

temp=P1; //

temp= temp&0xf0;

while(temp!=0xf0)

{           temp=P1;         //此句非常重要

switch(temp)

{

case 0xed : num=5;

break;

case 0xdd : num=6;

break;

case 0xbd : num=7;

break;

case 0x7d : num=8;

break;

}

/*        while(temp!=0xf0)

{

temp=P1;

temp=temp&0xf0;

}        */

P0=0;

P2=smgduan[num];

}

}

P1=0xfb;

temp=P1;

temp=temp&0xf0;

while(temp!=0xf0)

{

delay(500);

temp=P1; //

temp= temp&0xf0;

while(temp!=0xf0)

{           temp=P1;         //此句非常重要

switch(temp)

{

case 0xeb : num=1;

break;

case 0xdb : num=2;

break;

case 0xbb : num=3;

break;

case 0x7b : num=4;

break;

}

while(temp!=0xf0)

{

temp=P1;

temp=temp&0xf0;

}

P0=0;

P2=smgduan[num];

}

}

P1=0xf7;

temp=P1;

temp=temp&0xf0;

while(temp!=0xf0)

{

delay(500);

temp=P1; //

temp= temp&0xf0;

while(temp!=0xf0)

{           temp=P1;         //此句非常重要

switch(temp)

{

case 0xe7 : num=1;

break;

case 0xd7 : num=2;

break;

case 0xb7 : num=3;

break;

case 0x77 : num=4;

break;

}

while(temp!=0xf0)

{

temp=P1;

temp=temp&0xf0;

}

P0=0;

P2=smgduan[num];

}

}

}

}

1.jpg

(243.22 KB, 下载次数: 1)

2020-5-22 22:08 上传

384cb4e21e9a76f136ee23e1e74ab0df.gif

1858ebd83462849153babc3551f87f86.gif

3f829e29e76caa8c3b1f630a6b27d58d.gif

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值