#include <reg52.h> #define uint unsigned int #define uchar unsigned char sbit k1=P3^2; sbit k2=P3^3; uchar duan[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};//阴极管的代码 数组 char num=0;//定义一个数调用数组的数据
void delay(uint i) { while(i--); } main() { while(1) { if(k1==0) { delay(10000); if(k1==0) { num++; if(num==10) num=0; while(k1==0); P2=~duan[num]; } } if(k2==0) { delay(10000); if(k2==0) { num--; if(num==-1) num=9; while(k2==0) P2=~duan[num]; } } } }
归去来兮