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.
IRremote library should be fully compatible with Uno R4 and you might have either old version or some different version than listed in https://www.arduino.cc/reference/en/libraries/irremote/
I tried your code by selecting Uno R4 Minima and only I had to install the IRremote library (in "Sketch" -> "Add Library" -> "Manage libraries" (or CTRL+SHIFT+I) then typed "irremote" into the search and install).
Using library IRremote at version 4.3.0 in folder: C:\Users\m\Documents\Arduino\libraries\IRremote
"C:\\Users\\m\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\7-2017q4/bin/arm-none-eabi-size" -A "C:\\Users\\m\\AppData\\Local\\Temp\\arduino\\sketches\\D52ECE48380979A802CA96953101D2E8/sketch_mar14a.ino.elf"
Sketch uses 54668 bytes (20%) of program storage space. Maximum is 262144 bytes.
Global variables use 4960 bytes (15%) of dynamic memory, leaving 27808 bytes for local variables. Maximum is 32768 bytes.