0
点赞
收藏
分享

微信扫一扫

独立按键控制LED状态

佳简诚锄 2022-01-06 阅读 126

#include <REGX52.H>
#include <INTRINS.H>

void Delay1ms(unsigned int xms)        
{
    unsigned char i, j;
    while(xms)
    {
        _nop_();
        i = 2;
        j = 199;
        do
        {
            while (--j);
        } while (--i);
        xms--;
    }
    
}

void main()
{
    while(1)
        {
            if(P3_1==0)
            {
                Delay1ms(20);
                while(P3_1==0)
                {
                
                }
                Delay1ms(20);
                P2_0=~P2_0;
            }
        }

}

举报

相关推荐

0 条评论