Can't run Uno R3 code on R4 Wifi

Hello. I have some code that I can use to turn my TV off and on with an arduino nano and an IR LED. It works great. However, I want to run it on an uno r4 wifi so it can be controlled remotely. When I upload the same code to the uno r4, I get this error: (I put it in a block so its not so bad to read.

/*
/Users/-/Documents/Arduino/libraries/IRremote/irISR.cpp:18:5: error: expected constructor, destructor, or type conversion before '(' token
 ISR (TIMER_INTR_NAME)
     ^
/Users/-/Documents/Arduino/libraries/IRremote/irRecv.cpp: In member function 'void IRrecv::enableIRIn()':
/Users/-/Documents/Arduino/libraries/IRremote/irRecv.cpp:105:2: error: 'cli' was not declared in this scope
  cli();
  ^~~
/Users/-/Documents/Arduino/libraries/IRremote/irRecv.cpp:105:2: note: suggested alternative: 'cbi'
  cli();
  ^~~
  cbi
In file included from /Users/-/Documents/Arduino/libraries/IRremote/IRremote.h:24:0,
                 from /Users/-/Documents/Arduino/libraries/IRremote/irRecv.cpp:1:
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:236:3: error: 'TCCR2A' was not declared in this scope
   TCCR2A = _BV(WGM21); \
   ^
/Users/-/Documents/Arduino/libraries/IRremote/irRecv.cpp:110:2: note: in expansion of macro 'TIMER_CONFIG_NORMAL'
  TIMER_CONFIG_NORMAL();
  ^~~~~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:236:16: error: 'WGM21' was not declared in this scope
   TCCR2A = _BV(WGM21); \
                ^
/Users/-/Documents/Arduino/libraries/IRremote/irRecv.cpp:110:2: note: in expansion of macro 'TIMER_CONFIG_NORMAL'
  TIMER_CONFIG_NORMAL();
  ^~~~~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:236:12: error: '_BV' was not declared in this scope
   TCCR2A = _BV(WGM21); \
            ^
/Users/-/Documents/Arduino/libraries/IRremote/irRecv.cpp:110:2: note: in expansion of macro 'TIMER_CONFIG_NORMAL'
  TIMER_CONFIG_NORMAL();
  ^~~~~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:236:12: note: suggested alternative: '_B'
   TCCR2A = _BV(WGM21); \
            ^
/Users/-/Documents/Arduino/libraries/IRremote/irRecv.cpp:110:2: note: in expansion of macro 'TIMER_CONFIG_NORMAL'
  TIMER_CONFIG_NORMAL();
  ^~~~~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:237:3: error: 'TCCR2B' was not declared in this scope
   TCCR2B = _BV(CS21); \
   ^
/Users/-/Documents/Arduino/libraries/IRremote/irRecv.cpp:110:2: note: in expansion of macro 'TIMER_CONFIG_NORMAL'
  TIMER_CONFIG_NORMAL();
  ^~~~~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:237:16: error: 'CS21' was not declared in this scope
   TCCR2B = _BV(CS21); \
                ^
/Users/-/Documents/Arduino/libraries/IRremote/irRecv.cpp:110:2: note: in expansion of macro 'TIMER_CONFIG_NORMAL'
  TIMER_CONFIG_NORMAL();
  ^~~~~~~~~~~~~~~~~~~
In file included from /Users/-/Documents/Arduino/libraries/IRremote/IRremote.h:24:0,
                 from /Users/-/Documents/Arduino/libraries/IRremote/irSend.cpp:1:
/Users/-/Documents/Arduino/libraries/IRremote/irSend.cpp: In member function 'void IRsend::mark(int)':
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:210:30: error: 'TCCR2A' was not declared in this scope
 #define TIMER_ENABLE_PWM    (TCCR2A |= _BV(COM2B1))
                              ^
/Users/-/Documents/Arduino/libraries/IRremote/irSend.cpp:24:2: note: in expansion of macro 'TIMER_ENABLE_PWM'
  TIMER_ENABLE_PWM; // Enable pin 3 PWM output
  ^~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:237:16: note: suggested alternative: 'CS'
   TCCR2B = _BV(CS21); \
                ^
/Users/-/Documents/Arduino/libraries/IRremote/irRecv.cpp:110:2: note: in expansion of macro 'TIMER_CONFIG_NORMAL'
  TIMER_CONFIG_NORMAL();
  ^~~~~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:238:3: error: 'OCR2A' was not declared in this scope
   OCR2A  = TIMER_COUNT_TOP / 8; \
   ^
/Users/-/Documents/Arduino/libraries/IRremote/irRecv.cpp:110:2: note: in expansion of macro 'TIMER_CONFIG_NORMAL'
  TIMER_CONFIG_NORMAL();
  ^~~~~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:239:3: error: 'TCNT2' was not declared in this scope
   TCNT2  = 0; \
   ^
/Users/-/Documents/Arduino/libraries/IRremote/irRecv.cpp:110:2: note: in expansion of macro 'TIMER_CONFIG_NORMAL'
  TIMER_CONFIG_NORMAL();
  ^~~~~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:210:44: error: 'COM2B1' was not declared in this scope
 #define TIMER_ENABLE_PWM    (TCCR2A |= _BV(COM2B1))
                                            ^
/Users/-/Documents/Arduino/libraries/IRremote/irSend.cpp:24:2: note: in expansion of macro 'TIMER_ENABLE_PWM'
  TIMER_ENABLE_PWM; // Enable pin 3 PWM output
  ^~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:239:3: note: suggested alternative: 'SCNx32'
   TCNT2  = 0; \
   ^
/Users/-/Documents/Arduino/libraries/IRremote/irRecv.cpp:110:2: note: in expansion of macro 'TIMER_CONFIG_NORMAL'
  TIMER_CONFIG_NORMAL();
  ^~~~~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:212:30: error: 'TIMSK2' was not declared in this scope
 #define TIMER_ENABLE_INTR   (TIMSK2 = _BV(OCIE2A))
                              ^
/Users/-/Documents/Arduino/libraries/IRremote/irRecv.cpp:113:2: note: in expansion of macro 'TIMER_ENABLE_INTR'
  TIMER_ENABLE_INTR;
  ^~~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:212:43: error: 'OCIE2A' was not declared in this scope
 #define TIMER_ENABLE_INTR   (TIMSK2 = _BV(OCIE2A))
                                           ^
/Users/-/Documents/Arduino/libraries/IRremote/irRecv.cpp:113:2: note: in expansion of macro 'TIMER_ENABLE_INTR'
  TIMER_ENABLE_INTR;
  ^~~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:212:39: error: '_BV' was not declared in this scope
 #define TIMER_ENABLE_INTR   (TIMSK2 = _BV(OCIE2A))
                                       ^
/Users/-/Documents/Arduino/libraries/IRremote/irRecv.cpp:113:2: note: in expansion of macro 'TIMER_ENABLE_INTR'
  TIMER_ENABLE_INTR;
  ^~~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:210:40: error: '_BV' was not declared in this scope
 #define TIMER_ENABLE_PWM    (TCCR2A |= _BV(COM2B1))
                                        ^
/Users/-/Documents/Arduino/libraries/IRremote/irSend.cpp:24:2: note: in expansion of macro 'TIMER_ENABLE_PWM'
  TIMER_ENABLE_PWM; // Enable pin 3 PWM output
  ^~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:210:40: note: suggested alternative: '_B'
 #define TIMER_ENABLE_PWM    (TCCR2A |= _BV(COM2B1))
                                        ^
/Users/-/Documents/Arduino/libraries/IRremote/irSend.cpp:24:2: note: in expansion of macro 'TIMER_ENABLE_PWM'
  TIMER_ENABLE_PWM; // Enable pin 3 PWM output
  ^~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/irSend.cpp: In member function 'void IRsend::space(int)':
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:211:30: error: 'TCCR2A' was not declared in this scope
 #define TIMER_DISABLE_PWM   (TCCR2A &= ~(_BV(COM2B1)))
                              ^
/Users/-/Documents/Arduino/libraries/IRremote/irSend.cpp:35:2: note: in expansion of macro 'TIMER_DISABLE_PWM'
  TIMER_DISABLE_PWM; // Disable pin 3 PWM output
  ^~~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:212:39: note: suggested alternative: '_B'
 #define TIMER_ENABLE_INTR   (TIMSK2 = _BV(OCIE2A))
                                       ^
/Users/-/Documents/Arduino/libraries/IRremote/irRecv.cpp:113:2: note: in expansion of macro 'TIMER_ENABLE_INTR'
  TIMER_ENABLE_INTR;
  ^~~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/irRecv.cpp:117:2: error: 'sei' was not declared in this scope
  sei();  // enable interrupts
  ^~~
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:211:46: error: 'COM2B1' was not declared in this scope
 #define TIMER_DISABLE_PWM   (TCCR2A &= ~(_BV(COM2B1)))
                                              ^
/Users/-/Documents/Arduino/libraries/IRremote/irSend.cpp:35:2: note: in expansion of macro 'TIMER_DISABLE_PWM'
  TIMER_DISABLE_PWM; // Disable pin 3 PWM output
  ^~~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/irRecv.cpp:117:2: note: suggested alternative: 'sbi'
  sei();  // enable interrupts
  ^~~
  sbi
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:211:42: error: '_BV' was not declared in this scope
 #define TIMER_DISABLE_PWM   (TCCR2A &= ~(_BV(COM2B1)))
                                          ^
/Users/-/Documents/Arduino/libraries/IRremote/irSend.cpp:35:2: note: in expansion of macro 'TIMER_DISABLE_PWM'
  TIMER_DISABLE_PWM; // Disable pin 3 PWM output
  ^~~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:211:42: note: suggested alternative: '_B'
 #define TIMER_DISABLE_PWM   (TCCR2A &= ~(_BV(COM2B1)))
                                          ^
/Users/-/Documents/Arduino/libraries/IRremote/irSend.cpp:35:2: note: in expansion of macro 'TIMER_DISABLE_PWM'
  TIMER_DISABLE_PWM; // Disable pin 3 PWM output
  ^~~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/irSend.cpp: In member function 'void IRsend::enableIROut(int)':
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:213:30: error: 'TIMSK2' was not declared in this scope
 #define TIMER_DISABLE_INTR  (TIMSK2 = 0)
                              ^
/Users/-/Documents/Arduino/libraries/IRremote/irSend.cpp:54:2: note: in expansion of macro 'TIMER_DISABLE_INTR'
  TIMER_DISABLE_INTR; //Timer2 Overflow Interrupt
  ^~~~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:218:2: error: 'TCCR2A' was not declared in this scope
  TCCR2A               = _BV(WGM20); \
  ^
/Users/-/Documents/Arduino/libraries/IRremote/irSend.cpp:64:2: note: in expansion of macro 'TIMER_CONFIG_KHZ'
  TIMER_CONFIG_KHZ(khz);
  ^~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:218:29: error: 'WGM20' was not declared in this scope
  TCCR2A               = _BV(WGM20); \
                             ^
/Users/-/Documents/Arduino/libraries/IRremote/irSend.cpp:64:2: note: in expansion of macro 'TIMER_CONFIG_KHZ'
  TIMER_CONFIG_KHZ(khz);
  ^~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:218:25: error: '_BV' was not declared in this scope
  TCCR2A               = _BV(WGM20); \
                         ^
/Users/-/Documents/Arduino/libraries/IRremote/irSend.cpp:64:2: note: in expansion of macro 'TIMER_CONFIG_KHZ'
  TIMER_CONFIG_KHZ(khz);
  ^~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:218:25: note: suggested alternative: '_B'
  TCCR2A               = _BV(WGM20); \
                         ^
/Users/-/Documents/Arduino/libraries/IRremote/irSend.cpp:64:2: note: in expansion of macro 'TIMER_CONFIG_KHZ'
  TIMER_CONFIG_KHZ(khz);
  ^~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:219:2: error: 'TCCR2B' was not declared in this scope
  TCCR2B               = _BV(WGM22) | _BV(CS20); \
  ^
/Users/-/Documents/Arduino/libraries/IRremote/irSend.cpp:64:2: note: in expansion of macro 'TIMER_CONFIG_KHZ'
  TIMER_CONFIG_KHZ(khz);
  ^~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:219:29: error: 'WGM22' was not declared in this scope
  TCCR2B               = _BV(WGM22) | _BV(CS20); \
                             ^
/Users/-/Documents/Arduino/libraries/IRremote/irSend.cpp:64:2: note: in expansion of macro 'TIMER_CONFIG_KHZ'
  TIMER_CONFIG_KHZ(khz);
  ^~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:219:42: error: 'CS20' was not declared in this scope
  TCCR2B               = _BV(WGM22) | _BV(CS20); \
                                          ^
/Users/-/Documents/Arduino/libraries/IRremote/irSend.cpp:64:2: note: in expansion of macro 'TIMER_CONFIG_KHZ'
  TIMER_CONFIG_KHZ(khz);
  ^~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:219:42: note: suggested alternative: 'CS'
  TCCR2B               = _BV(WGM22) | _BV(CS20); \
                                          ^
/Users/-/Documents/Arduino/libraries/IRremote/irSend.cpp:64:2: note: in expansion of macro 'TIMER_CONFIG_KHZ'
  TIMER_CONFIG_KHZ(khz);
  ^~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:220:2: error: 'OCR2A' was not declared in this scope
  OCR2A                = pwmval; \
  ^
/Users/-/Documents/Arduino/libraries/IRremote/irSend.cpp:64:2: note: in expansion of macro 'TIMER_CONFIG_KHZ'
  TIMER_CONFIG_KHZ(khz);
  ^~~~~~~~~~~~~~~~
/Users/-/Documents/Arduino/libraries/IRremote/IRremoteInt.h:221:2: error: 'OCR2B' was not declared in this scope
  OCR2B                = pwmval / 3; \
  ^
/Users/-/Documents/Arduino/libraries/IRremote/irSend.cpp:64:2: note: in expansion of macro 'TIMER_CONFIG_KHZ'
  TIMER_CONFIG_KHZ(khz);
  ^~~~~~~~~~~~~~~~

exit status 1

Compilation error: exit status 1
*/

This is the code which I am uploading:

#include <IRremote.h>

int LED = 13;
IRsend irsend;

void setup() {
    pinMode(LED, OUTPUT); 
    pinMode(7,INPUT_PULLUP); 
}

void loop() {  
    if (digitalRead(7) == HIGH){
        digitalWrite(LED, HIGH);
        for (int i = 0; i < 3; i++) {
            irsend.sendSony(0xa90, 12); // 12 bit wide Sony TV power code
            delay(40);
        }
     } 
     else digitalWrite(LED, LOW);
     
     delay(100);  
}

Does anybody have any ideas why the code is working fine on the nano but gives this error when uploaded to the uno r4? Thanks a lot.

Well, the Arduino Uno R4 has a different microcontroller (Rensas RA4M1) than the Arduino Nano (Atmega328). For this reason, the register accesses of the source code no longer fit.

The software is not compatible with the microcontroller used.

How should I go about making it work with the Uno R4 then? Is it not the same language?

It is not a question of the programming language. It is a question of programming.

Hello. I appreciate the articles, but I looked through them and I couldn't figure out what I needed to change. Do you know if the timer pin is different, or if my issue is something else. Sorry for the questions, but I'm pretty new to arduino so still trying to understand this stuff. Thanks a lot.

Ok, good to know. Ill try and figure out another way around it then. Thanks for the response.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.