[Control] 'Klik-aan Klik-uit'

This piece of C++ (Arduino) code is for controlling dutch Klik-aan Klik-uit or KaKu remote controlled powersockets. If it receives @@pwr111*# it switches on and when it receives @@pwr000*# it […]

This piece of C++ (Arduino) code is for controlling dutch Klik-aan Klik-uit or KaKu remote controlled powersockets. If it receives

@@pwr111*#

it switches on and when it receives

@@pwr000*#

it switches off. With the checksumcode somewhere else on this site you can also check if that string is correct.

This switches the B1 setting of the Klikaan klikuit remote controlled power sockets introduction package. These used to be sold at the Gamma.

Parts list

  • C++ controller (Arduino)
  • RF emitter
  • KaKu receiver

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Klik-Aan-Klik-Uit Arduino Interface
// Copyright and origin unknown
 
char buffer[20]="@@pwr111*# ";
 
//For KaKu
char pwron[12] = "@@pwr111*#";
char pwroff[12] = "@@pwr000*#";
int kakupin = 13;
 
void setup () {
 
  Serial.begin(9600);
 
  if(strncmp(buffer, pwron, 8) == 0){ //Power aan
    outputKakuRFSignal(16, 1);
    Serial.println("on");
    delay(10000);
    outputKakuRFSignal(16, 1);
  }
  else if(strncmp(buffer, pwroff, 8) == 0){ //Power uit
    outputKakuRFSignal(16, 0);
    Serial.println("off");
    delay(100000);
    outputKakuRFSignal(16, 0);
    delay(100000);
  }
}
 
void loop() {}
 
void outputKakuRFSignal(unsigned char channel, unsigned char command) {
  int count = 0;
  while (count < 100) {      outputKakuRFSignalSeq(channel, command);     delay(4);     count++;   } } void outputKakuRFSignalSeq(unsigned char channel, unsigned char command) {   //letters   outputKakuBit(0);   outputKakuBit((channel & B00010000) >> 4);
  outputKakuBit(0);
  outputKakuBit((channel & B00100000) >> 5);
  outputKakuBit(0);
  outputKakuBit((channel & B01000000) >> 6);
  outputKakuBit(0);
  outputKakuBit((channel & B10000000) >> 7);
  //numbers
  outputKakuBit(0);
  outputKakuBit((channel & B00000001));
  outputKakuBit(0);
  outputKakuBit((channel & B00000010) >> 1);
  outputKakuBit(0);
  outputKakuBit((channel & B00000100) >> 2);
  outputKakuBit(0);
  outputKakuBit((channel &B00001000) >> 3);
  //unknown
  outputKakuBit(0);
  outputKakuBit(0);
  outputKakuBit(0);
  outputKakuBit(1);
  outputKakuBit(0);
  outputKakuBit(1);
  outputKakuBit(0);
  outputKakuBit(command);
  outputKakuBit(0);
}
 
void outputKakuBit(unsigned char theBit) {
  digitalWrite(kakupin, HIGH);
  delayMicroseconds(426);
  digitalWrite(kakupin, (theBit > 0) ? HIGH : LOW);
  delayMicroseconds(426);
  digitalWrite(kakupin, LOW);
  delayMicroseconds(426);
}