Home > other >  51 microcontroller - water lamp
51 microcontroller - water lamp

Time:03-15

#include

Sbit ADDR0 P1=^ 0;
P1 sbit ADDR1=^ 1;
Sbit ADDR2=p ^ 2;
Sbit ADDR3 P1=^ 3;
Sbit ENLED=P1 ^ 4;

Void main ()
{
Unsigned int I=0;//define variable I, used for software delay
Unsigned char CNT=0;//define counter variable (CNT), to control the displacement of

ENLED=0;
ADDR3=1;
ADDR2=1;
ADDR1=1;
ADDR0=0;

While (1)//the main loop, an infinite loop execution of the loop body statement
{
P0=~ (0 x01 & lt; for (i=0; i<20000; i++);//software delay
cnt++;//shift counter variable from 1
If (CNT & gt;=8)//count more than 7, again starting from 0
{
CNT=0;
}
}
}

CodePudding user response:

https://blog.csdn.net/xianfajushi/article/details/82279726 calculation model and the commonly used water lamp code

CodePudding user response:

Look at the code, define four use? To say the shrimps?
Nickname is reminds me of the classical poetry: luminous wine glass, wine to drink immediately pipa rush, ZuiWo battlefield MoXiao, ancient in several people back,

CodePudding user response:

Haven't said to ask what problem??

CodePudding user response:



LED small light circuit diagram

We can learn to control pin P0.0 after 74 hc245 control DB0, P0.1 control
DB1... P0.7 control DB7, we also learn a byte is eight, if we write a P0, it represents the P0.0
To all P0.7 8 bits, such as we write P0=0 xfe; Is converted to binary 0 b11111110, so light LED small lights program,

CodePudding user response:

If you ask is P1 mouth on the definition of the word, useless, you light water control in P0 mouth, if your program has reached to the effect, then remove P1 on definition, still can use,

CodePudding user response:

OK,,,,,,,,,,,,,,
  • Related