Compile errors in IRremote with Leonardo

Hi all

I'm making a project using a Leo board to pickup IR signals and send keyboard strokes to my HTPC. That's the plan anyway. The sketch I've made compiles and works on a Uno, but I get a pageful of errors by changing the board type to Leo. (I find the serial out from the Uno was too hard to grab with the Windows HTPC, so I'm hoping the keyboard library for the Leo will work. But I'm not getting that far.) The top of my sketch is

#include <Arduino.h> // I''d read in another forum thread with similar errors that this might help, it didn't
#include <IRremote.h>
haven't even included the keyboard library yet.

I'm using the IDE 1.0.1 and the errors are

Apple_remote.cpp: In function ‘void loop()’:
Apple_remote.cpp:57:41: error: invalid conversion from ‘const char*’ to ‘uint8_t {aka unsigned char}’ [-fpermissive]
In file included from /usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h:66:0,
                 from /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:193,
                 from Apple_remote.cpp:1:
/usr/share/arduino/hardware/arduino/cores/arduino/USBAPI.h:41:17: error:   initializing argument 1 of ‘virtual size_t Serial_::write(uint8_t)’ [-fpermissive]
Apple_remote.cpp:59:41: error: invalid conversion from ‘const char*’ to ‘uint8_t {aka unsigned char}’ [-fpermissive]
In file included from /usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h:66:0,
                 from /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:193,
                 from Apple_remote.cpp:1:
/usr/share/arduino/hardware/arduino/cores/arduino/USBAPI.h:41:17: error:   initializing argument 1 of ‘virtual size_t Serial_::write(uint8_t)’ [-fpermissive]
Apple_remote.cpp:61:41: error: invalid conversion from ‘const char*’ to ‘uint8_t {aka unsigned char}’ [-fpermissive]
In file included from /usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h:66:0,
                 from /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:193,
                 from Apple_remote.cpp:1:
/usr/share/arduino/hardware/arduino/cores/arduino/USBAPI.h:41:17: error:   initializing argument 1 of ‘virtual size_t Serial_::write(uint8_t)’ [-fpermissive]
Apple_remote.cpp:63:41: error: invalid conversion from ‘const char*’ to ‘uint8_t {aka unsigned char}’ [-fpermissive]
In file included from /usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h:66:0,
                 from /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:193,
                 from Apple_remote.cpp:1:
/usr/share/arduino/hardware/arduino/cores/arduino/USBAPI.h:41:17: error:   initializing argument 1 of ‘virtual size_t Serial_::write(uint8_t)’ [-fpermissive]
Apple_remote.cpp:65:41: error: invalid conversion from ‘const char*’ to ‘uint8_t {aka unsigned char}’ [-fpermissive]
In file included from /usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h:66:0,
                 from /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:193,
                 from Apple_remote.cpp:1:
/usr/share/arduino/hardware/arduino/cores/arduino/USBAPI.h:41:17: error:   initializing argument 1 of ‘virtual size_t Serial_::write(uint8_t)’ [-fpermissive]
Apple_remote.cpp:69:38: error: invalid conversion from ‘const char*’ to ‘uint8_t {aka unsigned char}’ [-fpermissive]
In file included from /usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h:66:0,
                 from /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:193,
                 from Apple_remote.cpp:1:
/usr/share/arduino/hardware/arduino/cores/arduino/USBAPI.h:41:17: error:   initializing argument 1 of ‘virtual size_t Serial_::write(uint8_t)’ [-fpermissive]

I'd be very grateful for help

I'm using the IDE 1.0.1 and the errors are

Those errors are, in the absence of evidence to the contrary, coming from your code, which you seem to have neglected to post.

Knowing something about which IRremote library you are using would be helpful, too.

My apologies. I am using the IR library from GitHub - Arduino-IRremote/Arduino-IRremote: Infrared remote library for Arduino: send and receive infrared signals with multiple protocols

My code so far is

//#include <Arduino.h>
#include <IRremote.h> 
#include <IRremoteInt.h> // have tried including / not including this


int receiver = 9; 
int acker = 7;

IRrecv irrecv(receiver); // create instance of 'irrecv'

decode_results results;

void setup()
{
  Serial.begin(9600); // for serial monitor output
  irrecv.enableIRIn();
  pinMode(acker, OUTPUT);

//  Serial.println("Starting serial monitor");

}

void blip() {
  digitalWrite(acker, HIGH); delay(50);  digitalWrite(acker, LOW);
}

void loop()
{

  int keyval;

  if (irrecv.decode(&results)) // have we received an IR signal?

  {
    

    keyval= results.value;


  switch (keyval) {

      case 	2011254978:	Serial.write('K'); break;

      case 	2011246786:	Serial.write("J"); break;

      case 	2011271362:	Serial.write("H"); break;

      case 	2011259074:	Serial.write("L"); break;

      case 	2011283650:	Serial.write("M"); break;

      case 	2011298498:	Serial.write(" "); break;

 //     case             -1:      Serial.write("EOT"); break;

      case 	15042  :	Serial.write("R"); break;

      

    //  default: Serial.write(keyval); break;

  }

blip();


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

  } 

}

I had also tried the (Leo specific?) library from Google Code Archive - Long-term storage for Google Code Project Hosting.
and received the same results.

I'm using an Apple remote, the outputs are just the vi direction keys, I actually want cursor key codes sent. This compiles and runs on a Uno, and gives me the errors in the first post if I change the board type to Leo in the IDE.

I downloaded the library, fired up Arduino 1.0.5, pasted your code, and got two errors about duplicate symbols. I commented out the IRremoteInt.h include statement, and tried again. Now, only one "error" message:

Binary sketch size: 11,296 bytes (of a 28,672 byte maximum)

One error... oh wait that was funny :slight_smile: I didn't think my code was at fault. Using 1.0.5 does indeed fix whatever the problem was.