rc-switch send (Arduino UNO)

rc-switch send - Osbeck - 曾经很有思想

(You can also use any other I/O Pin of your Arduino instead of Pin #10)

Transmission methods

There are three methods to send raw codes:

Binary string

send(string binaryCode)

Sends the binary string.

#include<RCSwitch.h>

RCSwitch mySwitch =RCSwitch();

void setup(){
  mySwitch.enableTransmit(10);  // Using Pin #10
}

void loop(){
  mySwitch.send("000000000001010100010001");
  delay(1000);  
}

Decimal value

send(int decimalCode, int bitLength)

Same as the first one but using the decimal value. The bit length is needed to zero-fill the binary code.

#include<RCSwitch.h>

RCSwitch mySwitch =RCSwitch();

void setup(){
  mySwitch.enableTransmit(10);  // Using Pin #10
}

void loop(){
  mySwitch.send(5393,24);
  delay(1000);  
}

Tri-state string

sendTriState(string triStateCode)

Tri-state codes are according to the data sheets of some encoding chips. Take a look at this blogpost if you are interested in details.

#include<RCSwitch.h>

RCSwitch mySwitch =RCSwitch();

void setup(){
  mySwitch.enableTransmit(10);  // Using Pin #10
}

void loop(){
  mySwitch.sendTriState("00000FFF0F0F");
  delay(1000);  
}

发表评论

电子邮件地址不会被公开。 必填项已用*标注