So I'm trying to turn an ON LED OFF or an OFF LED ON using a TV Remote. In the #define line, I write the hex code received from pressing the designated button on the TV remote. However, during compilation, an error saying unable to find numeric literal operator 'operator""DE74847' appears. I've scoured the web and can't come up with a solution.

#include <IRremote.h>
#include <IRremoteInt.h>
int ledPin = 13;
int IRPin = 3;

#define code1 0575

IRrecv irrecv(IRPin);
decode_results results;
void setup()
  pinMode(ledPin, OUTPUT);
void loop()
  if (irrecv.decode(&results))
  unsigned int value = results.value;
  int ledState  = digitalRead(ledPin);
    case code1:
    if (ledState = HIGH)
      digitalWrite(ledPin, LOW);
      digitalWrite(ledPin, HIGH);
    digitalWrite (ledPin, LOW);
   unsigned int value = results.value;

Here's the code. Please help.

  • Could you add in the full error you receive, please?
    – Mark Smith
    Dec 2, 2016 at 13:05
  • Try putting the #define line before the #include lines. If the define is being used in the included files they wont see it as it is now. Dec 2, 2016 at 13:10
  • 1
    From the error you give, I can't see why you'd think the problem is with the define. It also seems like the code you've provided is different from the code that gave the error.
    – Gerben
    Dec 2, 2016 at 13:31
  • Check the error line number. It might be that you have entered characters that are not allowed in a literal number. Dec 2, 2016 at 13:42
  • You have to prefix HEX numbers with 0x so the compiler knows it's HEX. 0575 is an octal number, not a HEX number. DE74847 is a random string of characters that it can't understand. Use 0xDE74847 instead.
    – Majenko
    Dec 2, 2016 at 13:51

1 Answer 1


Your problem is that you don't know how to form hexadecimal numbers.

In your code (in future, if you have an error in the code please post the code that is causing the error, not something else entirely - it makes it nigh on impossible for people without my psychic abilities to answer your question) you have defined a macro containing what you think is a hexadecimal number. In fact it's just a random string of characters and the compiler doesn't know what to make of it:

#define code1 DE74847

So in your switch construct, when code1 gets replaced with the content of the macro, you end up with:

switch (value) {
    case DE74847:

The compiler has no idea what a DE74847 is.

Numbers other than decimal numbers (0-9 and the decimal point) are identified by the use of a prefix:

  • 0b... is binary
  • 0 is octal (in your completely different code you have the number 0575, which is actually octal, and represents the decimal value 381)
  • 0x is hexadecimal.

So adding 0x to the start of your hexadecimal value will tell the compiler to treat it as hexadecimal:

#define code1 0xDE74847

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.