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();
      }
    }
    

      

  • 相关阅读:
    SSM框架--详细整合教程
    ssh--整合注意事项
    SSH--三大框架整合原理
    springMVC的流程
    java框架问题整理
    集合的体系
    java异常机制
    java知识点
    Java编程思想【Thinking in java】
    实验三 指令实验(一)
  • 原文地址:https://www.cnblogs.com/kekeoutlook/p/8207103.html
Copyright © 2011-2022 走看看