forked from MetalSeed/stc51_demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
1.7.c
44 lines (41 loc) · 1.1 KB
/
1.7.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*********************************方法三******************************
* 描述 : 该程序用于学习 LED流水灯 的控制方法。
8个LED会进行流水灯的演示
***********************************************************************/
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
/********************************************************************
* 名称 : Delay()
* 功能 : 延时,延时时间为 10ms * del
* 输入 : del
* 输出 : 无
***********************************************************************/
void Delay(uint del)
{
uint i,j;
for(i=0; i<del; i++)
for(j=0; j<1827; j++)
;
}
/********************************************************************
* 名称 : Main()
* 功能 : 实现灯的闪烁
* 输入 : 无
* 输出 : 无
***********************************************************************/
void Main(void)
{
uchar i, temp;
while(1)
{
temp = 0xfe;
for(i=0; i<8; i++)
{
P0 = temp; //把值赋给P1口
Delay(10); //延时(10毫秒 * j)秒
temp = temp << 1; //值右移一位
temp = temp | 0x01;
}
}
}