标题: 独立按键控制数码管加减法要求显示(-10——10) [打印本页]

作者: -Xu    时间: 2019-5-31 15:48
标题: 独立按键控制数码管加减法要求显示(-10——10)
#include<stc15.h>
#include<intrins.h>
#include<gpio.h>
#define uchar unsigned char
#define uint unsigned int
#include<595hc.h>
sbit SW17=P3^2;
sbit SW18=P3^3;
uint counter=0;
void Delay10ms()       
{
        unsigned char i, j;

        i = 108;
        j = 145;
        do
        {
                while (--j);
        } while (--i);
}
void main(void)
{
  gpio();
  while(1)
  {
    if(SW17==0)
        {
          Delay10ms();
          if(SW17==0)
          {
            counter++;
                if(counter>10)counter=0;
        }
          while(SW17==0);
          }
          if(SW18==0)
          {
           Delay10ms();
           if(SW18==0)
           {
           if(counter!=0)
           {
             counter--;
                 }
                }
                while(SW18==0);
        }
        Dis_buf[7]=counter%10;
        Dis_buf[6]=counter/10%10;
//        Dis_buf[5]=counter/100%10;
//        Dis_buf[4]=counter/1000%10;
//        Dis_buf[3]=counter/10000%10;
           display();
        }
}






欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1