单片机交流
直播中

郑成枝

7年用户 1267经验值
私信 关注
[问答]

萌新求助,求大佬分享一个STC89C52流水灯实验参考教程

萌新求助,求大佬分享一个STC89C52流水灯实验参考教程

回帖(1)

叶紫薇

2021-10-15 16:38:56
1.参考教程:

清翔51单片机教程
2.基本原理 :

移位和延迟
3.程序 :

#include
#include //标准库函数
#define uint unsigned int
#define uchar unsigned char
uchar temp;        //LED灯相关变量
//毫秒级延时函数定义
void delay(uint z)
{
        uint x,y;
        for(x = z; x > 0; x--)
                for(y = 114; y > 0; y--);
}
void main()
{
        temp = 0xfe;
        P1 = temp; //1111 1110
        delay(11111);//流水灯开始的延迟
    //进入循环开始流程灯
        while(1)
        {   temp = _crol_(temp, 1);//左移一位
                P1 = temp;          //再赋给P1
                delay(500);
        }
}
举报

更多回帖

发帖
×
20
完善资料,
赚取积分