前言:
现时看官们对“单片机for是什么指令”可能比较重视,小伙伴们都需要知道一些“单片机for是什么指令”的相关知识。那么小编同时在网上收集了一些有关“单片机for是什么指令””的相关文章,希望小伙伴们能喜欢,各位老铁们快快来了解一下吧!/////////////////////////////////////////////
按 一次P3.7 , P2.5上LED闪5次do while
////////////////////////////////////////////
#include <reg51.h>
void delay ();
sbit led0=P2^5;
sbit sw0=P3^7;
void main (main)
{
unsigned char t;
while(1)
{
t=0;
if (sw0==0)
{
do
{
led0=0;
delay();
led0=1;
delay ();
t++;
}
while (t<5);
}
}
}
void delay ()
{
unsigned int a;
a=50000;
while (a--);
}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
按 一次P3.7 , P2.5上LED闪7次: For写法
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
#include <reg51.h>
void delay(unsigned int i);
sbit sw0=P3^7;
sbit led0=P2^0;
void main()
{
unsigned char t;
t=0;
while(1)
{
if(sw0==0)
{
for(t=0;t<7;t++)
{
led0=0;
delay(50000);
led0=1;
delay(50000);
}
}
}
}
void delay(unsigned int i)
{
unsigned int a;
a=i;
while(a--);
}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
按 一次P3.7 , P2.5上LED闪5次WHILE写法
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
#include <reg51.h>
void delay(unsigned int i);
sbit sw0=P3^7;
sbit led0=P2^0;
void main()
{
unsigned char t;
//t=0;
while(1)
{
if(sw0==0)
{
t=0;//
while (t<5)
{
t++;
led0=0;
delay(50000);
led0=1;
delay(50000);
}
}
}
}
void delay(unsigned int i)
{
unsigned int a;
a=i;
while(a--);
}
标签: #单片机for是什么指令