Home > Back-end >  MCU course design, the design pattern running water light, Internet applications are always running
MCU course design, the design pattern running water light, Internet applications are always running

Time:09-19

#include//51 series microcontroller definition file
# define uchar unsigned char//define unsigned characters
# define uint unsigned int//define unsigned integer

Void delay (uint);//declare delay function
Void main (void)
{
Uint I;
Uchar temp.

TCON=0 x05;
IE=0 x85;
PX1=1;
PX0=0;


While (1)
{
Temp=0 x01;
for(i=0; i<8; I++)//8 water lights flashing one by one
{
P0=temp;
Delay (100);//time delay function called
Temp<=1;
}
Temp=0 x80;
for(i=0; i<8; Eight i++)//water reverse by flashing lights
{
P0=temp;
Delay (150);//time delay function called
Temp>=1;
}
Temp=0 xfe;
for(i=0; i<8; I++)//eight lights all light in turn water
{
P0=temp;
Delay (150);//time delay function called
Temp<=1;
}
Temp=0 x7f;
for(i=0; i<8; I++)//all eight water lights, in turn, reverse light
{
P0=temp;
Delay (150);//time delay function called
Temp>=1;
}
Temp=0 x03;
for(i=0; i<4. I++)//two lamp order light water
{
P0=temp;
Delay (150);
Temp<=2;
}

Temp=0 x30;
for(i=0; i<3; I++)//water reverse light lamp
{
P0=temp;
Delay (150);
Temp>=2;
}
Temp=0 x07;
for(i=0; i<3; I++)//3
{
P0=temp;
Delay (150);
Temp<=3;
}

Temp=0 xe0-0xfc;
for(i=0; i<3; I++)//3 water reverse light lamp
{
P0=temp;
Delay (150);
Temp>=3;
}
Temp=0 x0f;
for(i=0; i<3; I++)//4 ge
{
P0=temp;
Delay (150);
Temp<=4;
}

Temp=0 xf0;
for(i=0; i<3; I++)//4 light water reverse light
{
P0=temp;
Delay (150);
Temp>=4;
}
}
}


Void int0 () interrupt 0
{
Uint I;
Uchar temp.
While (1)
{
Temp=0 x01;
for(i=0; i<8; I++)//8 water lights flashing one by one
{
P0=temp;
Delay (800);//time delay function called
Temp<=1;
}
Temp=0 x80;
for(i=0; i<8; Eight i++)//water reverse by flashing lights
{
P0=temp;
Delay (800);//time delay function called
Temp>=1;
}
Temp=0 xfe;
for(i=0; i<8; I++)//eight lights all light in turn water
{
P0=temp;
Delay (800);//time delay function called
Temp<=1;
}
Temp=0 x7f;
for(i=0; i<8; I++)//all eight water lights, in turn, reverse light
{
P0=temp;
Delay (800);//time delay function called
Temp>=1;
}
Temp=0 x03;
for(i=0; i<4. I++)//two lamp order light water
{
P0=temp;
Delay (800);
Temp<=2;
}

Temp=0 x30;
for(i=0; i<3; I++)//water reverse light lamp
{
P0=temp;
Delay (800);
Temp>=2;
}
Temp=0 x07;
for(i=0; i<3; I++)//3 lamp order light water
{
P0=temp;
Delay (800);
Temp<=3;
}

Temp=0 xe0-0xfc;
for(i=0; i<3; I++)//3 water reverse light lamp
{
P0=temp;
Delay (800);
Temp>=3;
}
}
Temp=0 x0f;
for(i=0; i<3; I++)//4 lamp order light water
{
P0=temp;
Delay (800);
Temp<=4;
}

Temp=0 xf0;
for(i=0; i<3; I++)//4 light water reverse light
{
P0=temp;
Delay (800);
Temp>=4;
}
}

Void delay (uint t)//
delay functions are defined{
The register uint bt;
for(; t; T -)
For (bt=0; Bt<255; Bt++);
}

CodePudding user response:

Code function at the end of the day is not others to help you see or interpretation or comment; But by myself calm down and take a long enough time and energy to do it yourself step or set a breakpoint or step to perform to a certain intermediate result shows or written to the log file analysis step by step,
Remind: cow x teacher cannot replace the student understand and use the toilet!
Single step debugging and set breakpoint debugging is one of the programmers must master the skills,
  • Related