Last active
November 27, 2018 22:49
-
-
Save blurrryy/f82bbc79efff3d5471b83926a09ff601 to your computer and use it in GitHub Desktop.
HEITECH Funksteckdose 27209 / Neue Version ohne DIP-Schalter / Raspberry Pi / RCSwitch / Working Example / Funktioniert
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
#include "../rc-switch/RCSwitch.h" | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <iostream> | |
#include <string> | |
#define SWITCHCOUNT 3 | |
#define PIN 0 | |
int args[SWITCHCOUNT][2]; | |
RCSwitch mySwitch = RCSwitch(); | |
void setArgs() | |
{ | |
// Just choose 1 of the possible 4 codes you get by sniffing. | |
// Switch 1 | |
args[0][0] = 00000000; // off | |
args[0][1] = 00000000; // on | |
// Switch 2 | |
args[1][0] = 00000000; // off | |
args[1][1] = 00000000; // on | |
// Switch 3 | |
args[2][0] = 00000000; // off | |
args[2][1] = 00000000; // on | |
} | |
void controlLight(int swNum, int swCase) | |
{ | |
std::string strCase; | |
if (swCase == 1) | |
{ | |
strCase = " on"; | |
} | |
else | |
{ | |
strCase = " off"; | |
} | |
std::cout << "Switching " << swNum + 1 << strCase << std::endl; | |
mySwitch.send(args[swNum][swCase], 24); | |
} | |
int main(int argc, char *argv[]) | |
{ | |
if (wiringPiSetup() == -1) | |
return 1; | |
setArgs(); | |
mySwitch.enableTransmit(PIN); | |
mySwitch.setProtocol(4); // Protocol 4 makes it work | |
controlLight(atoi(argv[1]) - 1, atoi(argv[2])); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compile:
Run: (Switch 1 on)