zoukankan      html  css  js  c++  java
  • Arduino 433 自定义接受

    /*
      Simple example for receiving
      
      https://github.com/sui77/rc-switch/
    */
    
    #include <RCSwitch.h>
    #define led1 10  
    #define led2 11  
    RCSwitch mySwitch = RCSwitch();
    
    void setup() {
      Serial.begin(9600);
        pinMode(led1, OUTPUT);    
          pinMode(led2, OUTPUT);    
      mySwitch.enableReceive(0);  // Receiver on interrupt 0 => that is pin #2
    }
    
    void loop() {
      if (mySwitch.available()) {
        
        int value = mySwitch.getReceivedValue();
        
        if (value == 0) {
          Serial.print("Unknown encoding");
        } else {
          if (value ==17) { 
            if( digitalRead(led1)==0){
            digitalWrite(led1, HIGH);
            }
            else{
               digitalWrite(led1, LOW);
              }
            }
          if (value ==18) { 
    
             if( digitalRead(led2)==0){
            digitalWrite(led2, HIGH);
            }
            else{
               digitalWrite(led2, LOW);
              }
          
          
          }
          Serial.print("Received ");
          Serial.print( mySwitch.getReceivedValue() );
          Serial.print(" / ");
          Serial.print( mySwitch.getReceivedBitlength() );
          Serial.print("bit ");
          Serial.print("Protocol: ");
          Serial.println( mySwitch.getReceivedProtocol() );
        }
    
        mySwitch.resetAvailable();
      }
    }
    

      

  • 相关阅读:
    NET 获取实例所表示的日期是星期几
    NET npoi 保存文件
    快速排序
    JAVA poi 合并单元格
    JAVA poi 帮助类
    JAVA 字符串编码转换
    NET npoi 合并单元值处理
    NET npoi帮助类
    Task的暂停,继续,取消
    .net ref与out之间区别
  • 原文地址:https://www.cnblogs.com/kekeoutlook/p/8207103.html
Copyright © 2011-2022 走看看