Bootstrap

数码管显示1314-520(普中51-单核-A2)

#include<reg52.h>
#include<intrins.h>

typedef unsigned int uint;
typedef unsigned char uchar;
#define LED P0
sbit tube2=P2^2;
sbit tube3=P2^3;
sbit tube4=P2^4;

uint code num[]={0x3f , 0x06 , 0x5b , 0x4f , 0x66 , //高电平控制亮		  //显示数字
				 0x6d , 0x7d , 0x07 , 0x7f , 0x6f };

void delay(uint i);
void run();
void main(){
	while(1){
		run();
	}
}

void delay(uint i){
	while(i--);
}

void run(){
	tube2=1;tube3=1;tube4=1;
	 LED=num[1];
	 delay(100);
	 tube2=0;tube3=1;tube4=1;
	 LED=num[3];
	 delay(100);
	 tube2=1;tube3=0;tube4=1;
	 LED=num[1];
	 delay(100);
	 tube2=0;tube3=0;tube4=1;
	 LED=num[4];
	 delay(100);
	 tube2=1;tube3=1;tube4=0;
	 LED=0x40;
	 delay(100);
	 tube2=0;tube3=1;tube4=0;
	 LED=num[5];
	 delay(100);
	 tube2=1;tube3=0;tube4=0;
	 LED=num[2];
	 delay(100);
	 tube2=0;tube3=0;tube4=0;
	 LED=num[0];
	 delay(100);
}

在这里插入图片描述

;