Current location - Education and Training Encyclopedia - Graduation thesis - Design paper of single chip microcomputer running water lamp
Design paper of single chip microcomputer running water lamp
Function 1: # includes

sbit p 1_0=p 1^0; //Define IO ports

Void delay02s(void) // 0.2 second delay subroutine

{

Unsigned characters I, j, k; //Define 3 unsigned character data.

for(I = 20; I>0; I-)// Used for cyclic delay.

for(j = 20; j & gt0; j -)

for(k = 248; k & gt0; k-);

}

Void main(void) // Every C language program has one and only one main function.

{

While( 1) // The loop condition is always true, and the following procedure is always executed.

{

p 1 _ 0 = 0; // I/O port P 1.0 outputs low level, and the small light is on.

delay 02s(); //Delay 0.2 seconds.

p 1 _ 0 = 1; // I/O port P 1.0 outputs high level, and the small light goes out.

delay 02s(); //Delay 0.2 seconds.

}

}

Function two and function three can only be realized by changing I/O!