zoukankan      html  css  js  c++  java
  • 基于51单片机,蜂鸣器和led每秒1滴1亮的程序

    #include <reg52.h>
    
    #define uchar unsigned char
    #define uint unsigned int
    
    int seccnt,m=0;
    char tzsta,msta;
    
    sbit led=P2^0;
    sbit beep=P1^5;
    
    void ini()//定时器0
    {
        seccnt=0;
        msta=tzsta=0;
        TMOD=0x01;
        TH0=0x0FF;
        TL0=0x9C;
        TR0=1;
    }
    
    void on()//蜂鸣器和灯的功能
    {
        if(m<=500)
            {
                beep=~beep;
            }
            if(m>=10000)
            {
                led = ~led;
                m=0;
            }
    }
    
    void main()
    {
        ini();
        while(1)
        {
            while(TF0==0);
            TL0=0x9C;
            TH0=0x0FF;
                TF0=0;
            m=m+1;
            on();
            
        }
    }
  • 相关阅读:
    502 bad gateway错误的网关
    nodejs发展
    edgejs
    websocket nodejs实例
    nodejs原码
    node案例
    node 与php整合
    node c#
    jquery
    express
  • 原文地址:https://www.cnblogs.com/action0/p/12668838.html
Copyright © 2011-2022 走看看