📄 secondswaterlights.txt
字号:
/******************************************************************
60秒流水灯循环左移,60秒后LED全部快速闪烁****/
#include <reg52.h> //头文件
#include <intrins.h> //头文件
#define uint unsigned int //宏定义
#define uchar unsigned char //宏定义
uchar temp; //定义变量temp
void delay(uint z); //延时程序声明
uint a,c;
void main()//进入主程序
{
temp=0xfe; //赋值
P0=temp; //赋值
c=60; //初值,60就是60秒。
for(a=c;a>0;a--)
{
delay (1000); //延时
temp=_crol_(temp,1); /*_crol_是循环左移,_cror_是循环右移,
括号内第一个参数temp是要移动的变量。,后面是要移动几位*/
P0=temp; //赋值
}
while(1) //进入主循环
{
P0=0X00;
delay(100);
P0=0XFF;
delay(100);
}
}
//下面延时程序内容
void delay(uint z) //
{
uint x,y; //两个局部变量x,y
for(x=z;x>0;x--) //for语句
for(y=115;y>0;y--); /*这个延时程序当Z等于1时候大概延时1ms时间。Z等于1000时候延 时1分钟*/
}
/******************************************************************
60秒流水灯循环左移,每秒P3.7口外接喇叭响一声,60秒后LED全部快速闪烁同时喇叭发声,****/
#include <reg52.h> //头文件
#include <intrins.h> //头文件
#define uint unsigned int //宏定义
#define uchar unsigned char //宏定义
uchar temp; //定义变量temp
void delay(uint z); //延时程序声明
uint a,c;
sbit BELL=P3^7;
void main()//进入主程序
{
temp=0xfe; //赋值
P0=temp; //赋值
c=60; //初值,60就是60秒。
for(a=c;a>0;a--)
{
BELL=0;
delay (1000); //延时
temp=_crol_(temp,1); /*_crol_是循环左移,_cror_是循环右移,
括号内第一个参数temp是要移动的变量。,后面是要移动几位*/
P0=temp; //赋值
}
while(1) //进入主循环
{
P0=0X00;
BELL=1;
delay(100);
P0=0XFF;
BELL=0;
delay(100);
}
}
//下面延时程序内容
void delay(uint z) //
{
uint x,y; //两个局部变量x,y
for(x=z;x>0;x--) //for语句
for(y=115;y>0;y--); /*这个延时程序当Z等于1时候大概延时1ms时间。Z等于1000时候延 时1分钟*/
BELL=1;
}
/******************************************************************
60秒流水灯循环左移,每秒P3.7口外接喇叭响一声,60秒后LED全部快速闪烁同时喇叭发声,前50秒每秒闪烁一下,后10秒每秒闪烁两下****/
#include <reg52.h> //头文件
#include <intrins.h> //头文件
#define uint unsigned int //宏定义
#define uchar unsigned char //宏定义
uchar temp; //定义变量temp
void delay(uint z); //延时程序声明
uint a,c;
sbit BELL=P3^7;
void main()//进入主程序
{
temp=0xfe; //赋值
P0=temp; //赋值
c=50; //初值,60就是60秒。
for(a=c;a>0;a--)
{
BELL=0;
delay (1000); //延时
temp=_crol_(temp,1); /*_crol_是循环左移,_cror_是循环右移,
括号内第一个参数temp是要移动的变量。,后面是要移动几位*/
P0=temp; //赋值
}
c=20;//赋值,当delay等于500时候就是半秒延时程序所以10分钟就等于20.
for(a=c;a>0;a--)
{
BELL=0;
delay (500); //延时
temp=_crol_(temp,1); /*_crol_是循环左移,_cror_是循环右移,
括号内第一个参数temp是要移动的变量。,后面是要移动几位*/
P0=temp; //赋值
}
while(1) //进入主循环
{
P0=0X00;
BELL=1;
delay(100);
P0=0XFF;
BELL=0;
delay(100);
}
}
//下面延时程序内容
void delay(uint z) //
{
uint x,y; //两个局部变量x,y
for(x=z;x>0;x--) //for语句
for(y=115;y>0;y--); /*这个延时程序当Z等于1时候大概延时1ms时间。Z等于1000时候延 时1分钟*/
BELL=1;
}
/******************************************************************
60秒流水灯循环左移,每秒P3.7口外接喇叭响一声,60秒后LED全部快速闪烁同时喇叭发声,前40秒每秒闪烁一下,之后10秒每秒闪烁两下,最后10秒每秒闪烁4下****/
#include <reg52.h> //头文件
#include <intrins.h> //头文件
#define uint unsigned int //宏定义
#define uchar unsigned char //宏定义
uchar temp; //定义变量temp
void delay(uint z); //延时程序声明
uint a,c;
sbit BELL=P3^7;
void main()//进入主程序
{
temp=0xfe; //赋值
P0=temp; //赋值
c=40; //初值,60就是60秒。
for(a=c;a>0;a--)
{
BELL=0;
delay (1000); //延时
temp=_crol_(temp,1); /*_crol_是循环左移,_cror_是循环右移,
括号内第一个参数temp是要移动的变量。,后面是要移动几位*/
P0=temp; //赋值
}
c=20;//赋值,当delay等于500时候就是半秒延时程序所以10分钟就等于20.
for(a=c;a>0;a--)
{
BELL=0;
delay (500); //延时
temp=_crol_(temp,1); /*_crol_是循环左移,_cror_是循环右移,
括号内第一个参数temp是要移动的变量。,后面是要移动几位*/
P0=temp; //赋值
}
c=40;//赋值,当delay等于500时候就是半秒延时程序所以10分钟就等于20.
for(a=c;a>0;a--)
{
BELL=0;
delay (250); //延时
temp=_crol_(temp,1); /*_crol_是循环左移,_cror_是循环右移,
括号内第一个参数temp是要移动的变量。,后面是要移动几位*/
P0=temp; //赋值
}
while(1) //进入主循环
{
P0=0X00;
BELL=1;
delay(100);
P0=0XFF;
BELL=0;
delay(100);
}
}
//下面延时程序内容
void delay(uint z) //
{
uint x,y; //两个局部变量x,y
for(x=z;x>0;x--) //for语句
for(y=115;y>0;y--); /*这个延时程序当Z等于1时候大概延时1ms时间。Z等于1000时候延 时1分钟*/
BELL=1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -