[Control] 'Klik-aan Klik-uit'

kakuheader

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

Tim Zaman

Engineer from The Netherlands (1988). Living in Delft. MSc degree in Robotics. Is on a PhD research position on development of imaging devices. For contact see 'About' in the above menu.

You may also like...

1 Response

  1. TonyTrimb says:

    Cool! deze code zocht ik Thx!

Leave a Reply

Your email address will not be published. Required fields are marked *


× 8 = sixteen

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">