#include <RCSwitch.h> RCSwitch mySwitch = RCSwitch(); void setup() { Serial.begin(9600); // Transmitter is connected to Arduino Pin #10 mySwitch.enableTransmit(10); // Optional set pulse length. mySwitch.setPulseLength(321); // set protocol (default is 1, will work for most outlets) // mySwitch.setProtocol(2); // Optional set number of transmission repetitions. // mySwitch.setRepeatTransmit(15); pinMode(13,OUTPUT); } void loop() { mySwitch.send("100000101100100011001000"); digitalWrite(13,HIGH); delay(500); digitalWrite(13,LOW); delay(10000); }Here is the code which opens and closes my garage door (simulates button 1) every 10 seconds. It also flashes the on-board LED to indicate a command has been sent.
#include <RCSwitch.h> RCSwitch mySwitch = RCSwitch(); void setup() { Serial.begin(9600); // Transmitter is connected to Arduino Pin #10 mySwitch.enableTransmit(10); // Optional set pulse length. mySwitch.setPulseLength(321); // set protocol (default is 1, will work for most outlets) // mySwitch.setProtocol(2); // Optional set number of transmission repetitions. // mySwitch.setRepeatTransmit(15); pinMode(13,OUTPUT); } void loop() { mySwitch.send("100000101100100011001000"); digitalWrite(13,HIGH); delay(500); digitalWrite(13,LOW); delay(10000); }
Project orginially shared by liwenyip via Instructables