Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
rcswitch 433
// This #include statement was automatically added by the Particle IDE.
#include "RCSwitch/RCSwitch.h"
/*
This is a minimal sketch without using the library at all but only works for
the 10 pole dip switch sockets. It saves a lot of memory and thus might be
very useful to use with ATTinys :)
http://code.google.com/p/rc-switch/
*/
int RCLpin = D7; // modified run with a Spark Core
void setup() {
pinMode(RCLpin, OUTPUT);
}
void loop() {
RCLswitch(0b010001000001); // DIPs at rc power outlet: 0100010000 ON:01
delay(2000);
RCLswitch(0b010001000010); // DIPs at rc power outlet: 0100010000 OFF:10
delay(2000);
}
void RCLswitch(uint16_t code) {
for (int nRepeat=0; nRepeat<6; nRepeat++) {
for (int i=4; i<16; i++) {
RCLtransmit(1,3);
if (((code << (i-4)) & 2048) > 0) {
RCLtransmit(1,3);
} else {
RCLtransmit(3,1);
}
}
RCLtransmit(1,31);
}
}
void RCLtransmit(int nHighPulses, int nLowPulses) {
digitalWrite(RCLpin, HIGH);
delayMicroseconds( 350 * nHighPulses);
digitalWrite(RCLpin, LOW);
delayMicroseconds( 350 * nLowPulses);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment