Created
August 13, 2015 09:26
-
-
Save gepatto/774018d95116b76f5780 to your computer and use it in GitHub Desktop.
rcswitch 433
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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