IR remote controle



  • I found a nice project using an IR remote controle, it is designed for Arduino but I have no idea how to convert the code to MySensors. Who can help? ```

    /*Code belongs to this video https://www.youtube.com/watch?v=wqZwQnh6ZtQ
    writen by Moz for YouTube changel logmaker360.
    13-04-2016

    code works on a car mp3 remote controller
    */

    #include <IRremote.h>
    int RECV_PIN = 6;
    int BLUE_LED = 13;
    int RED_LED = 12;

    IRrecv irrecv(RECV_PIN);
    decode_results results;

    void setup() {
    // initialize the digital pin as an output.
    pinMode(RECV_PIN, INPUT);
    pinMode(BLUE_LED, OUTPUT);
    pinMode(RED_LED, OUTPUT);
    irrecv.enableIRIn(); // Start the receiver
    Serial.begin(9600);
    }
    void loop() {
    int i=0;
    if (irrecv.decode(&results)) {

    translateIR();
    unknownRemoter();

     irrecv.resume(); // Receive the next value
    

    }
    }

    void translateIR() // takes action based on IR code received describing Car MP3 IR codes
    {

    switch(results.value){
    case 0xFFA25D:
    Serial.println(" CH- ");
    break;
    case 0xFF629D:
    Serial.println(" CH ");
    break;
    case 0xFFE21D:
    Serial.println(" CH+ ");
    break;
    case 0xFF22DD:
    Serial.println(" blue LED off ");
    digitalWrite(13,LOW);
    break;
    case 0xFF02FD:
    Serial.println(" blue LED on ");
    digitalWrite(13, HIGH);
    break;
    case 0xFFC23D:
    Serial.println(" PLAY/PAUSE ");
    break;
    case 0xFFE01F:
    Serial.println(" VOL- ");
    break;
    case 0xFFA857:
    Serial.println(" VOL+ ");
    break;
    case 0xFF906F:
    Serial.println(" EQ ");
    break;
    case 0xFF6897:
    Serial.println(" 0 ");
    break;
    case 0xFF9867:
    Serial.println(" 100+ ");
    break;
    case 0xFFB04F:
    Serial.println(" 200+ ");
    break;
    case 0xFF30CF:
    Serial.println(" 1 ");
    break;

    case 0xFF18E7:
    Serial.println(" 2 ");
    break;

    case 0xFF7A85:
    Serial.println(" 3 ");
    break;

    case 0xFF10EF:
    Serial.println(" 4 ");
    break;

    case 0xFF38C7:
    Serial.println(" 5 ");
    break;

    case 0xFF5AA5:
    Serial.println(" 6 ");
    break;

    case 0xFF42BD:
    Serial.println(" 7 ");
    break;

    case 0xFF4AB5:
    Serial.println(" 8 ");
    break;

    case 0xFF52AD:
    Serial.println(" 9 ");
    break;

    default:
    Serial.print(" unknown button ");
    Serial.println(results.value, HEX);

    }

    delay(500);

    }

    void unknownRemoter(){ //this function is from an old remoter see video.
    long RED_LED_OFF = 0xFF40BF;
    long RED_LED_ON = 0xFF906F;
    long LAST_BUTTON = 0xFFD02F;

    if (results.value == RED_LED_OFF){
    Serial.println ("Red led off");
    digitalWrite(12,LOW);
    }
    else if (results.value == RED_LED_ON )
    {
    Serial.println ("Red led on");
    digitalWrite(12,HIGH);
    }
    else if (results.value == LAST_BUTTON )
    {
    Serial.println ("CAMERA IMAGE button");
    }else{
    Serial.print(" still an unknown button ");
    Serial.println(results.value, HEX);
    }
    }


  • Mod

    @dick you would need to put a "send" for every case you see with an IR code. The problem is how you want to handle the commands (create a binary child for each button or a single multi value child)



  • Thanks for the reply but this is probably to big for me. I wanted to make an IR remote to operate the most common use Mysensors in my house without starting the Domoticz app,The results I wanted to connect using an Event in domoticz


  • Hardware Contributor

    Do you want to make an ir remote, or do you want to use an existing remote ?

    If you want to make one, then make a MySensors remote control directly.
    If you want to use an existing remote control, then I would process like this :

    • make 2 arrays of the same size, one for bytes that contains the child id, one (not sure of the data type) for related IR codes. If you don't have too many codes then you can make one 2 dimensional array and use same data type for child ID and for IR code (not too many so not taking up too much memory)
    • in the presentation method, loop in the array and present all child ids as buttons (or scenes, up to you)
    • in the code, when you receive an IR code, loop in the IR codes array to find the code. Then get the related child id in the child id array, and send a "on" mysensors message for this child.


  • @nca78 I start experiment this weekend and will give it a try. Thanks for the ideas to make a working solution, in this case the use of an existing IR controle.


Log in to reply
 

Suggested Topics

  • 4
  • 8
  • 3
  • 2
  • 4
  • 9

12
Online

11.4k
Users

11.1k
Topics

112.7k
Posts