當前位置:編程學習大全網 - 編程軟體 - 八位動態數碼管,編程每按壹次鍵,數值加壹

八位動態數碼管,編程每按壹次鍵,數值加壹

//我只加到了9999。。

#include<reg52.h>

#define uchar unsigned char

#define uint unsigned int

uchar display_code[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};

uint Count=0;

sbit AN3=P2^0;

void delay()

{

uchar i;

for(i=250;i>0;i--);

}

void disp()

{

P3=0x01;

P0=display_code[Count/100/10];

delay();

P3=0x00;

P3=0x02;

P0=display_code[Count/100%10];

delay();

P3=0x00;

P3=0x04;

P0=display_code[Count/10];

delay();

P3=0x00;

P3=0x08;

P0=display_code[Count%10];

delay();

P3=0x00;

}

void main()

{

uint i;

while(1)

{

if(AN3==0)

{

Count++;

while(AN3==0);

if(Count>9999) Count=0;

}

for(i=100;i>0;i--)

{

disp();

}

}

}

  • 上一篇:QT是什麽意思?
  • 下一篇:html自閉合標簽有哪些
  • copyright 2024編程學習大全網