Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - CH45 1 and the display program of single chip microcomputer digital tube (cyclic right shift)
CH45 1 and the display program of single chip microcomputer digital tube (cyclic right shift)
Digital tube cyclic right shift # includes

#define DataPort P0 // If a data port is encountered in the data port definition program, it will be replaced by P0.

sbit latch 1=p2^6; //Define the latch enable port segment latch.

sbit latch2=p2^7; //bit latch

Unsigned character code DuanMa[]={0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8};

//Display segment code value 0 1234567.

Unsigned character code Ma Wei []={0x80, 0x40, 0x20, 0x 10, 0x08, 0x04, 0x02, 0x01};

//The corresponding digital tubes light up respectively, that is, the bit code.

Void Delay (unsigned integer t); //Function declaration

/* -

major function

- */

Master ()

{

Unsigned character I = 0;;

while( 1)

{

DataPort = Ma Wei [I]; //Access code

latch 2 = 1; //bit latch

latch 2 = 0;

data port = Duan ma[I]; //Get the display data and segment code.

latch 1 = 1; //segment latch

latch 1 = 0;

Delay (200); //Scan interval delay. Too long will flash, too short will cause double shadow.

i++;

If(8==i) // Detect that the 8-bit scan is completely completed? If scanning is completed, scan 8 bits from the first bit.

I = 0;

}

}

/* -

Delay function, the input parameter is unsigned integer t, and there is no return value.

Unsigned int is an unsigned integer variable whose value range is

0~65535

- */

Invalid delay (unsigned integer t)

{

while(-t);

}