Uploaded from my local repository
[433Utils_NP] / rc-switch / examples / TypeA_WithDIPSwitches_Lightweight / TypeA_WithDIPSwitches_Lightweight.ino
1 /*
2   This is a minimal sketch without using the library at all but only works for
3   the 10 pole dip switch sockets. It saves a lot of memory and thus might be 
4   very useful to use with ATTinys :)
5   
6   https://github.com/sui77/rc-switch/
7 */
8
9 int RCLpin = 7;
10
11 void setup() {
12     pinMode(RCLpin, OUTPUT);
13 }
14
15 void loop() {
16     RCLswitch(0b010001000001);  // DIPs an Steckdose: 0100010000 An:01
17     delay(2000);
18
19     RCLswitch(0b010001000010);  // DIPs an Steckdose: 0100010000 Aus:10
20     delay(2000);    
21 }
22
23 void RCLswitch(uint16_t code) {
24     for (int nRepeat=0; nRepeat<6; nRepeat++) {
25         for (int i=4; i<16; i++) {
26             RCLtransmit(1,3);
27             if (((code << (i-4)) & 2048) > 0) {
28                 RCLtransmit(1,3);
29             } else {
30                 RCLtransmit(3,1);
31             }
32         }
33         RCLtransmit(1,31);    
34     }
35 }
36
37 void RCLtransmit(int nHighPulses, int nLowPulses) {
38     digitalWrite(RCLpin, HIGH);
39     delayMicroseconds( 350 * nHighPulses);
40     digitalWrite(RCLpin, LOW);
41     delayMicroseconds( 350 * nLowPulses);
42 }
43
Contact me: dev (at) shalnoff (dot) com
PGP fingerprint: A6B8 3B23 6013 F18A 0C71 198B 83D8 C64D 917A 5717