OSC Triggering IR [Solved]

Hi,

I’ve been working on a project to send OSC commands to trigger IR codes to control a LED Light.

I’ve tested and have it working with the Arduino Uno with an Ethernet shield getting triggered via OSC on QLab. But I could only have a maximum of 8 OSC commands before it became too much for the Uno to handle. I then went and bought an Arduino Mega 2560 because it has more processing power but the code doesn’t work at all. It just comes up with an error in the serial

message decode error invalid.

any time I send any command (both programmed and unprogrammed commands).

I’m using the following libraries:
IR Remote (https://github.com/z3t0/Arduino-IRremote)
ArduinoOSC (GitHub - hideakitai/ArduinoOSC: OSC subscriber / publisher for Arduino)
Ethernet (https://github.com/arduino-libraries/Ethernet)

The code I’m using is the following.

#include <ArduinoOSC.h>
#include <IRremote.h>

// Ethernet Settings
const IPAddress ip(10, 0, 100, 1); // device ip
uint8_t mac[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB}; // device mac address

// ArduinoOSC
OscEthernet osc;
const char* host = "10.0.100.100"; // ip for sending OSC
const int recv_port = 10000; // listening port
const int send_port = 53000; // sending port

// IR Settings
IRsend irsend;
const int ledPin = 3;

// OSC ACTIONS

  // ir status
void IRStatusOn(OscMessage& m)
{
    Serial.print("[IR] On");
    Serial.println("");
    irsend.sendNEC(0xFFB04F, 32);
}
void IRStatusOff(OscMessage& m)
{
    Serial.print("[IR] Off");
    Serial.println("");
    irsend.sendNEC(0xFFF807, 32);
}

  // ir dim
void IRDimUp(OscMessage& m)
{
    Serial.print("[IR] Dim | Up");
    Serial.println("");
    irsend.sendNEC(0xFF906F, 32);
}
void IRDimDown(OscMessage& m)
{
    Serial.print("[IR] Dim | Down");
    Serial.println("");
    irsend.sendNEC(0xFFB847, 32);
}

  // ir colour (primary)
void IRColourRed(OscMessage& m)
{
    Serial.print("[IR] Colour | Red");
    Serial.println("");
    irsend.sendNEC(0xFF9867, 32);
}
void IRColourGreen(OscMessage& m)
{
    Serial.print("[IR] Colour | Green");
    Serial.println("");
    irsend.sendNEC(0xFFD827, 32);
}
void IRColourBlue(OscMessage& m)
{
    Serial.print("[IR] Colour | Blue");
    Serial.println("");
    irsend.sendNEC(0xFF8877, 32);
}
void IRColourWhite(OscMessage& m)
{
    Serial.print("[IR] Colour | White");
    Serial.println("");
    irsend.sendNEC(0xFFA857, 32);
}

  // ir colour (mixers)
void IRColourBloodOrange(OscMessage& m)
{
    Serial.print("[IR] Colour | Blood Orange {R1}");
    Serial.println("");
    irsend.sendNEC(0xFFE817, 32);
}
void IRColourOrange(OscMessage& m)
{
    Serial.print("[IR] Colour | Orange {R2}");
    Serial.println("");
    irsend.sendNEC(0xFF02FD, 32);
}
void IRColourBrightOrange(OscMessage& m)
{
    Serial.print("[IR] Colour | Bright Orange {R3}");
    Serial.println("");
    irsend.sendNEC(0xFF50AF, 32);
}
void IRColourYellow(OscMessage& m)
{
    Serial.print("[IR] Colour | Yellow {R4}");
    Serial.println("");
    irsend.sendNEC(0xFF38C7, 32);
}
void IRColourLime(OscMessage& m)
{
    Serial.print("[IR] Colour | Lime {G1}");
    Serial.println("");
    irsend.sendNEC(0xFF48B7, 32);
}
void IRColourCyan(OscMessage& m)
{
    Serial.print("[IR] Colour | Cyan {G2}");
    Serial.println("");
    irsend.sendNEC(0xFF32CD, 32);
}
void IRColourSeaGreen(OscMessage& m)
{
    Serial.print("[IR] Colour | Sea Green {G3}");
    Serial.println("");
    irsend.sendNEC(0xFF7887, 32);
}
void IRColourEmerald(OscMessage& m)
{
    Serial.print("[IR] Colour | Emerald {G4}");
    Serial.println("");
    irsend.sendNEC(0xFF28D7, 32);
}
void IRColourSkyBlue(OscMessage& m)
{
    Serial.print("[IR] Colour | Sky Blue {B1}");
    Serial.println("");
    irsend.sendNEC(0xFF6897, 32);
}
void IRColourPurple(OscMessage& m)
{
    Serial.print("[IR] Colour | Purple {B2}");
    Serial.println("");
    irsend.sendNEC(0xFF20DF, 32);
}
void IRColourMagenta(OscMessage& m)
{
    Serial.print("[IR] Colour | Magenta {B3}");
    Serial.println("");
    irsend.sendNEC(0xFF708F, 32);
}
void IRColourPink(OscMessage& m)
{
    Serial.print("[IR] Colour | Pink {B4}");
    Serial.println("");
    irsend.sendNEC(0xFFF00F, 32);
}

    // ir effects
void IREffectFlash(OscMessage& m)
{
    Serial.print("[IR] Effect | Flash");
    Serial.println("");
    irsend.sendNEC(0xFFB24D, 32);
}
void IREffectStrobe(OscMessage& m)
{
    Serial.print("[IR] Effect | Strobe {B4}");
    Serial.println("");
    irsend.sendNEC(0xFF00FF, 32);
}
void IREffectFade(OscMessage& m)
{
    Serial.print("[IR] Effect | Fade {B4}");
    Serial.println("");
    irsend.sendNEC(0xFF58A7, 32);
}
void IREffectSmooth(OscMessage& m)
{
    Serial.print("[IR] Effect | Smooth {B4}");
    Serial.println("");
    irsend.sendNEC(0xFF30CF, 32);
}

void setup()
{
    pinMode(ledPin, OUTPUT);
    Serial.begin(115200);

    // Ethernet Settings
    Ethernet.begin(mac, ip);

    // ArduinoOSC
    osc.begin(recv_port);

// OSC COMMANDS
    // ir status
    osc.subscribe("/ir/status/on", IRStatusOn);
    osc.subscribe("/ir/status/off", IRStatusOff);
    // ir dim
    osc.subscribe("/ir/dim/up", IRDimUp);
    osc.subscribe("/ir/dim/down", IRDimDown);
    // ir colour (primary)
    osc.subscribe("/ir/colour/red", IRColourRed);
    osc.subscribe("/ir/colour/green", IRColourGreen);
    osc.subscribe("/ir/colour/blue", IRColourBlue);
    osc.subscribe("/ir/colour/white", IRColourWhite);
    // ir colour (mixers)
    osc.subscribe("/ir/colour/bloodorange", IRColourBloodOrange);
    osc.subscribe("/ir/colour/orange", IRColourOrange);
    osc.subscribe("/ir/colour/brightorange", IRColourBrightOrange);
    osc.subscribe("/ir/colour/yellow", IRColourYellow);
    osc.subscribe("/ir/colour/lime", IRColourLime);
    osc.subscribe("/ir/colour/cyan", IRColourCyan);
    osc.subscribe("/ir/colour/seagreen", IRColourSeaGreen);
    osc.subscribe("/ir/colour/emerald", IRColourEmerald);
    osc.subscribe("/ir/colour/skyblue", IRColourSkyBlue);
    osc.subscribe("/ir/colour/purple", IRColourPurple);
    osc.subscribe("/ir/colour/magenta", IRColourMagenta);
    osc.subscribe("/ir/colour/pink", IRColourPink);
    // ir effects
    osc.subscribe("/ir/effect/flash", IREffectFlash);
    osc.subscribe("/ir/effect/strobe", IREffectStrobe);
    osc.subscribe("/ir/effect/fade", IREffectFade);
    osc.subscribe("/ir/effect/smooth", IREffectSmooth);
}

void loop()
{
    osc.parse();
}

I’ve tried cutting back the code also on the Mega to the one that works on the Uno and it’s still comes up with the same error. Tried modifying the code, using different OSC libraries. But haven’t been able to get anything to work and unsure of how to proceed from here.

Any help would be appreciated.

Cheers.

Ended up rewriting the code using a different OSC library and used a different pin number (9) for the IR LED.

Used the following libraries:
Ethernet (GitHub - arduino-libraries/Ethernet: Ethernet Library for Arduino)
IR Remote (https://github.com/z3t0/Arduino-IRremote)
OSC (GitHub - CNMAT/OSC: OSC: Arduino and Teensy implementation of OSC encoding)

The updated code is the following:

#include <Ethernet.h>
#include <EthernetUdp.h>
#include <SPI.h>
#include <OSCBundle.h>
#include <OSCBoards.h>
#include <IRremote.h>

// SETTINGS
  // Ethernet Settings
EthernetUDP udp;
IPAddress ip(10, 0, 100, 1); // device ip
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // device mac address
const unsigned int inPort = 10000; // listening port

// IR Settings
IRsend irsend;
const int ledPin = 9;


// OSC ACTIONS
  // IR Status
void IRStatusOn(OSCMessage &msg, int addrOffset ){
  Serial.print("[IR] ON"); Serial.println("");
  irsend.sendNEC(0xFFB04F, 32);
}
void IRStatusOff(OSCMessage &msg, int addrOffset ){
  Serial.print("[IR] OFF"); Serial.println("");
  irsend.sendNEC(0xFFF807, 32);
}
  // IR Dim
void IRDimUp(OSCMessage &msg, int addrOffset ){
  Serial.print("[IR] Dim | Up"); Serial.println("");
  irsend.sendNEC(0xFF906F, 32);
}
void IRDimDown(OSCMessage &msg, int addrOffset ){
  Serial.print("[IR] Dim | Down"); Serial.println("");
  irsend.sendNEC(0xFFB847, 32);
}
// IR Colour (Primary)
void IRColourRed(OSCMessage &msg, int addrOffset ){
  Serial.print("[IR] Colour | Red"); Serial.println("");
  irsend.sendNEC(0xFF9867, 32);
}
void IRColourGreen(OSCMessage &msg, int addrOffset ){
  Serial.print("[IR] Colour | Green"); Serial.println("");
  irsend.sendNEC(0xFFD827, 32);
}
void IRColourBlue(OSCMessage &msg, int addrOffset ){
  Serial.print("[IR] Colour | Blue"); Serial.println("");
  irsend.sendNEC(0xFF8877, 32);
}
void IRColourWhite(OSCMessage &msg, int addrOffset ){
  Serial.print("[IR] Colour | White"); Serial.println("");
  irsend.sendNEC(0xFFA857, 32);
}
// IR Colour (Mixers)
void IRColourR1(OSCMessage &msg, int addrOffset ){
  Serial.print("[IR] Colour | Red 1"); Serial.println("");
  irsend.sendNEC(0xFFE817, 32);
}
void IRColourR2(OSCMessage &msg, int addrOffset ){
  Serial.print("[IR] Colour | Red 2"); Serial.println("");
  irsend.sendNEC(0xFF02FD, 32);
}
void IRColourR3(OSCMessage &msg, int addrOffset ){
  Serial.print("[IR] Colour | Red 3"); Serial.println("");
  irsend.sendNEC(0xFF50AF, 32);
}
void IRColourR4(OSCMessage &msg, int addrOffset ){
  Serial.print("[IR] Colour | Red 4"); Serial.println("");
  irsend.sendNEC(0xFF38C7, 32);
}
void IRColourG1(OSCMessage &msg, int addrOffset ){
  Serial.print("[IR] Colour | Green 1"); Serial.println("");
  irsend.sendNEC(0xFF48B7, 32);
}
void IRColourG2(OSCMessage &msg, int addrOffset ){
  Serial.print("[IR] Colour | Green 2"); Serial.println("");
  irsend.sendNEC(0xFF32CD, 32);
}
void IRColourG3(OSCMessage &msg, int addrOffset ){
  Serial.print("[IR] Colour | Green 3"); Serial.println("");
  irsend.sendNEC(0xFF7887, 32);
}
void IRColourG4(OSCMessage &msg, int addrOffset ){
  Serial.print("[IR] Colour | Green 4"); Serial.println("");
  irsend.sendNEC(0xFF28D7, 32);
}
void IRColourB1(OSCMessage &msg, int addrOffset ){
  Serial.print("[IR] Colour | Blue 1"); Serial.println("");
  irsend.sendNEC(0xFF6897, 32);
}
void IRColourB2(OSCMessage &msg, int addrOffset ){
  Serial.print("[IR] Colour | Blue 2"); Serial.println("");
  irsend.sendNEC(0xFF20DF, 32);
}
void IRColourB3(OSCMessage &msg, int addrOffset ){
  Serial.print("[IR] Colour | Blue 3"); Serial.println("");
  irsend.sendNEC(0xFF708F, 32);
}
void IRColourB4(OSCMessage &msg, int addrOffset ){
  Serial.print("[IR] Colour | Blue 4"); Serial.println("");
  irsend.sendNEC(0xFFF00F, 32);
}
  //IR Effects
void IREffectFlash(OSCMessage &msg, int addrOffset ){
  Serial.print("[IR] Effect | Flash"); Serial.println("");
  irsend.sendNEC(0xFFB24D, 32);
}
void IREffectStrobe(OSCMessage &msg, int addrOffset ){
  Serial.print("[IR] Effect | Strobe"); Serial.println("");
  irsend.sendNEC(0xFF00FF, 32);
}
void IREffectFade(OSCMessage &msg, int addrOffset ){
  Serial.print("[IR] Effect | Fade"); Serial.println("");
  irsend.sendNEC(0xFF58A7, 32);
}
void IREffectSmooth(OSCMessage &msg, int addrOffset ){
  Serial.print("[IR] Effect | Smooth"); Serial.println("");
  irsend.sendNEC(0xFF30CF, 32);
}

//SETUP
void setup() {
  Ethernet.begin(mac,ip);
  udp.begin(inPort);
  pinMode(ledPin, OUTPUT);
  Serial.begin(115200); // serial port
}

// OSC COMMANDS
void loop(){
  OSCBundle osc;
  int size;

  if( (size = udp.parsePacket())>0)
  {
    while(size--)
      osc.fill(udp.read());
      // IR Status
    if(!osc.hasError())
      osc.route("/ir/status/on", IRStatusOn);
      osc.route("/ir/status/off", IRStatusOff);
      // IR Dim
      osc.route("/ir/dim/up", IRDimUp);
      osc.route("/ir/dim/down", IRDimDown);
      // IR Colour (Primary)
      osc.route("/ir/colour/red", IRColourRed);
      osc.route("/ir/colour/green", IRColourGreen);
      osc.route("/ir/colour/blue", IRColourBlue);
      osc.route("/ir/colour/white", IRColourWhite);
      // IR Colours (Mixers)
      osc.route("/ir/colour/r1", IRColourR1);
      osc.route("/ir/colour/r2", IRColourR2);
      osc.route("/ir/colour/r3", IRColourR3);
      osc.route("/ir/colour/r4", IRColourR4);
      osc.route("/ir/colour/g1", IRColourG1);
      osc.route("/ir/colour/g2", IRColourG2);
      osc.route("/ir/colour/g3", IRColourG3);
      osc.route("/ir/colour/g4", IRColourG4);
      osc.route("/ir/colour/b1", IRColourB1);
      osc.route("/ir/colour/b2", IRColourB2);
      osc.route("/ir/colour/b3", IRColourB3);
      osc.route("/ir/colour/b4", IRColourB4);
      // IR Effects
      osc.route("/ir/effect/flash", IREffectFlash);
      osc.route("/ir/effect/strobe", IREffectStrobe);
      osc.route("/ir/effect/fade", IREffectFade);
      osc.route("/ir/effect/smooth", IREffectSmooth);
   }
}