找回密码
 注册
搜索
热搜: 活动 交友 discuz
查看: 13|回复: 0

独立按键+流水灯

[复制链接]

65

主题

1

回帖

298

积分

管理员

积分
298
发表于 前天 00:25 | 显示全部楼层 |阅读模式
#include <REGX52.H>
#include <INTRINS.H>


void Delay1ms(unsigned int time)                //@11.0592MHz
{
        unsigned char i, j;
        while(time){
                        _nop_();
                        i = 2;
                        j = 199;
                        do
                        {
                                while (--j);
                        } while (--i);
                        time--;
        }
       
}



void main(){
        int js=1;
        while(1){
                if(P3_1==0){
                        Delay1ms(20);
                        while(P3_1==0);
                        Delay1ms(20);
                        P2=0xFF;
                        while(1){
                                Delay1ms(500);
                                if(js==1){
                                        js++;
                                        P2=P2<<1;
                                }else{
                                        js=1;
                                        P2=(P2<<1)+1;
                                }
                        }
                       
                }else if(P3_2==0){
                        Delay1ms(20);
                        while(P3_2==0);
                        Delay1ms(20);
                        P2=~P2;
                        }
        }
}

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|樱论坛

GMT+8, 2026-4-16 21:13 , Processed in 0.042680 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表