/*流水燈賦初值,大循環,延時,左移,賦值,延時,左移,賦值
延時子程序的流水燈*/
#include <reg52.h>
#include <intrins.h>
#define uint unsigned int //定義宏變量名隨便起如bbb
#define uchar unsigned char //定義宏變量名隨便起如aaa
uchar temp;//定義p1口的賦值名
void delay (uint z);//
void main()
{
temp=0xfe;//
P1=temp;
while (1)
{
delay(1000);
temp=_crol_(temp,1);//_crol_移位指令括號內1就是1位1位的移,以此內推。
P1=temp;
}
}
void delay (uint z)//
{
uint x,y;//
for (x=z;x>0;x--)//
for (y=30;y>0;y--);//
}
/*
sbit LED1=P1^0 ;//定義腳位名稱隨便起一個名
sbit LED2=P1^7 ;
unsigned int a ;//定義一個賦值名a或者其他,且賦值是0-65525之間
void main()
{
while(1) //等于0跳出等于1在下面大括號內循環
{
a=60000;
LED1=0;
while(a--); //a數值自減,到0后跳出
LED1=1;
a=50000;
LED2=0;
while(a--);
LED2=1;
}
}*/
|