B4R Question How to create new or update rIRremote library

Discussion in 'B4R Questions' started by bdunkleysmith, Nov 12, 2018.

  1. bdunkleysmith

    bdunkleysmith Member Licensed User

    Based on this project, I have the following code which I can compile in the Arduino IDE and it runs successfully on my breadboarded UNO. However I would like continue development in B4R rather than the Arduino IDE because I want to send characters via Bluetooth rather than hardware serial.

    I can handle re-writing the body of the code, however I am unsure what I need to do with the #include <skIRremote.h> part. I expect it needs to be converted to a library which would handle the call to irsend. The ssIRremote library was written by the author of the above project and he said that is just the Arduino IRremote library to which he added support for the Foxtel IQ remote. His library files are here.

    Would I be better working with the rIRremote library referenced here and modifying it based on the information above so it too will support for the Foxtel IQ remote?

    Thanks in anticipation of any guidance as I'm now well out of my depth,


     * Sending all Foxtel remote keys 
    as IR codes with IRsend
     * An IR 
    LED in series with a resistor (180r) must be connected to Arduino PWM pin 3 and GND long led lead to +ve.
     * Version 
    1.0 November 2018
     * Bryon Dunkley-Smith

    #include <skIRremote.h>
    IRsend irsend;

    char receivedChar;
    boolean newData = 

    void setup() {

    void loop() {

    void recvOneChar() {
     if (Serial.available() > 0) {
      receivedChar = Serial.read();
      newData = true;

    void showNewData() {
      if (newData == true) {
        case '0':
        sendIR(0x00, receivedChar); // IQ 0 command
        case '1':
        sendIR(0x01, receivedChar); // IQ 1 command
        case '2':
        sendIR(0x02, receivedChar); // IQ 2 command
        case '3':
        sendIR(0x03, receivedChar); // IQ 3 command
        case '4':
        sendIR(0x04, receivedChar); // IQ 4 command
        case '5':
        sendIR(0x05, receivedChar); // IQ 5 command
        case '6':
        sendIR(0x06, receivedChar); // IQ 6 command
        case '7':
        sendIR(0x07, receivedChar); // IQ 7 command
        case '8':
        sendIR(0x08, receivedChar); // IQ 8 command
        case '9':
        sendIR(0x09, receivedChar); // IQ 9 command
        case 'A':
        sendIR(0x0C, receivedChar); // IQ Power command
        case 'B':
        sendIR(0x0D, receivedChar); // IQ Mute command
        case 'C':
        sendIR(0x0F, receivedChar); // IQ Mute command
        case 'D':
        sendIR(0x10, receivedChar); // IQ Vol+ command
        case 'E':
        sendIR(0x11, receivedChar); // IQ Vol- command
        case 'F':
        sendIR(0x20, receivedChar); // IQ Chn+ command
        case 'G':
        sendIR(0x21, receivedChar); // IQ Chn- command
        case 'H':
        sendIR(0x28, receivedChar); // IQ Fwd command
        case 'I':
        sendIR(0x29, receivedChar); // IQ Rew command
        case 'J':
        sendIR(0x2C, receivedChar); // IQ Play command
        case 'K':
        sendIR(0x30, receivedChar); // IQ Pause command
        case 'L':
        sendIR(0x31, receivedChar); // IQ Stop command
        case 'M':
        sendIR(0x37, receivedChar); // IQ Record command
        case 'N':
        sendIR(0x38, receivedChar); // IQ AV command
        case 'O':
        sendIR(0x4E, receivedChar); // IQ Foxtel command
        case 'P':
        sendIR(0x54, receivedChar); // IQ Setup command
        case 'Q':
        sendIR(0x58, receivedChar); // IQ Up command
        case 'R':
        sendIR(0x59, receivedChar); // IQ Down command
        case 'S':
        sendIR(0x5A, receivedChar); // IQ Left command
        case 'T':
        sendIR(0x5B, receivedChar); // IQ Right command
        case 'U':
        sendIR(0x5C, receivedChar); // IQ Select command
        case 'V':
        sendIR(0x6D, receivedChar); // IQ Red command
        case 'W':
        sendIR(0x6E, receivedChar); // IQ Green command
        case 'X':
        sendIR(0x6F, receivedChar); // IQ Yellow command
        case 'Y':
        sendIR(0x70, receivedChar); // IQ Blue command
        case 'Z':
        sendIR(0x81, receivedChar); // IQ Help command
        case 'a':
        sendIR(0x83, receivedChar); // IQ Back command
        case 'b':
        sendIR(0xCC, receivedChar); // IQ TV Guide command
        case 'c':
        sendIR(0xD5, receivedChar); // IQ Box Office command
        case 'd':
        sendIR(0xF4, receivedChar); // IQ Planner command
        case 'e':
        sendIR(0xFD, receivedChar); // IQ Active command

    void sendIR(byte code, char rxdChar) {
      irsend.sendFox(code); // IQ command
      newData = false;
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. bdunkleysmith

    bdunkleysmith Member Licensed User

    Thanks Erel - that solution appears to be within my capability!

    Just to close this thread out I thought I'd post the code I finished up with based on your suggestion, in case it is of use to others:

    Sub Process_Globals
    Public sp As Serial
    Public ssp As SoftwareSerial
    Private astream As AsyncStreams
    Private receivedChar As Byte
    End Sub

    Private Sub AppStart
    End Sub

    Sub Astream_NewData (Buffer() As Byte)
    For Each char In Buffer
            receivedChar = char
    End Sub

    Sub AStream_Error
    End Sub

    Sub showNewData
    Select receivedChar
    Case 48 '0
                RunNative("sendIR"0x00'IQ 0 command
            Case 49 '1
                RunNative("sendIR"0x01'IQ 1 command
            Case 50 '2
                RunNative("sendIR"0x02'IQ 2 command
            Case 51 '3
                RunNative("sendIR"0x03'IQ 3 command
            Case 52 '4
                  RunNative("sendIR"0x04'IQ 4 command
            Case 53 '5
                  RunNative("sendIR"0x05'IQ 5 command
            Case 54 '6
                  RunNative("sendIR"0x06'IQ 6 command
            Case 55 '7
                  RunNative("sendIR"0x07'IQ 7 command
            Case 56 '8
                  RunNative("sendIR"0x08'IQ 8 command
            Case 57 '9
                  RunNative("sendIR"0x09'IQ 9 command
            Case 65 'A
                  RunNative("sendIR"0x0C'IQ Power command
            Case 66 'B
                RunNative("sendIR"0x0D'IQ Mute command
            Case 67 'C
                RunNative("sendIR"0x0F'IQ Mute command
            Case 68 'D
                RunNative("sendIR"0x10'IQ Vol+ command
            Case 69 'E
                  RunNative("sendIR"0x11'IQ Vol- command
            Case 70 'F
                  RunNative("sendIR"0x20'IQ Chn+ command
            Case 71 'G
                  RunNative("sendIR"0x21'IQ Chn- command
            Case 72 'H
                  RunNative("sendIR"0x28'IQ Fwd command
            Case 73 'I
                  RunNative("sendIR"0x29'IQ Rew command
            Case 74 'J
                  RunNative("sendIR"0x2C'IQ Play command
            Case 75 'K
                  RunNative("sendIR"0x30'IQ Pause command
            Case 76 'L
                  RunNative("sendIR"0x31'IQ Stop command
            Case 77 'M
                  RunNative("sendIR"0x37'IQ Record command
            Case 78 'N
                  RunNative("sendIR"0x38'IQ AV command
            Case 79 'O
                  RunNative("sendIR"0x4E'IQ Foxtel command
            Case 80 'P
                  RunNative("sendIR"0x54'IQ Setup command
            Case 81 'Q
                  RunNative("sendIR"0x58'IQ Up command
            Case 82 'R
                  RunNative("sendIR"0x59'IQ Down command
            Case 83 'S
                  RunNative("sendIR"0x5A'IQ Left command
            Case 84 'T
                  RunNative("sendIR"0x5B'IQ Right command
            Case 85 'U
                  RunNative("sendIR"0x5C'IQ Select command
            Case 86 'V
                  RunNative("sendIR"0x6D'IQ Red command
            Case 87 'W
                  RunNative("sendIR"0x6E'IQ Green command
            Case 88 'X
                  RunNative("sendIR"0x6F'IQ Yellow command
              Case 89 'Y
                  RunNative("sendIR"0x70'IQ Blue command
            Case 90 'Z
                  RunNative("sendIR"0x81'IQ Help command
            Case 97 'a
                  RunNative("sendIR"0x83'IQ Back command
            Case 98 'b
                  RunNative("sendIR"0xCC'IQ TV Guide command
            Case 99 'c
                  RunNative("sendIR"0xD5'IQ Box Office command
            Case 100 'd
                  RunNative("sendIR"0xF4'IQ Planner command
            Case 101 'e
                  RunNative("sendIR"0xFD'IQ Active command
        End Select
    End Sub

    #if C
    #include <skIRremote.h>
    IRsend irsend;
    void sendIR(B4R::Object* o) {
      irsend.sendFox(o->toULong()); // Send IQ command via IR
    #End if
    Note that this code also includes use of SoftwareSerial to which a Bluetooth module is connected so commands sent to my device from an Android app via Bluetooth is re-transmitted via IR to a Foxtel (pay tv) box.
    Erel and Mostez like this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice