单片机显示1-9

#include <reg51.h>
#define uchar unsigned char
sbit key=P1^0;
uchar i,j;

xianshima[3]={0xc0,0xf9,0xa4};

void delay ( i )
{

   while  (i--);
}

void main()
{
j=0;
while(1)
  {
     if(key==0)
     {
      delay(1000);
      P2=xianshima[j];
      j=j+1;
      while(key==0) ;
      }
   }
}

  

posted @ 2021-10-15 09:32  小kBlog  阅读(395)  评论(0编辑  收藏  举报