普中A2单片机单个数码管轮播0-7

 #include "reg52.h"
 typedef unsigned int u16;
 typedef unsigned int u8;
 
 sbit LSA=P2^2;
 sbit LSB=P2^3;
 sbit LSC=P2^4;
 unsigned char code table[]={
    
    0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07};
 void delay(u16 i){
    
    
 	 while(i--);
 }
 void Led(){
    
    
 	 u8 i;
	 for (i=0;i<8;i++){
    
    
	 
	   delay(4000);
	 	
	 		LSA=1;LSB=1;LSC=1;P0=table[i];	 
	 	 
		  delay(10000);
		  P0=0;
		
		 
	 }
 
 }
 void main(){
    
    
 	   while(1){
    
    
	   	 Led();
	   }
 	   
 }

Guess you like

Origin blog.csdn.net/weixin_43591127/article/details/121185657