How to use the IR library with an attiny using Arduino

This Instructable will tell you how to use the IR (infrared) library on an Attiny. I will be using an Attiny85 with an Arduino Uno. I won’t cover how to upload sketches to the Attiny just how to use the IR library with it. the best tutorial on uploading sketches I’ve found is this YouTube tutorial :

(a quck note and warning, You will need to have software serial working for the attiny (follow this instructable : or google it

How to use the IR library with an attiny using Arduino

Step 1: Getting the files

The main issues that you would come across when trying to use the IR library with an Attiny are errors like this:

C:\Program Files (x86)\Arduino\libraries\IRremote\IRremote.cpp:229: error: ‘TCCR2B’ was not declared in this scope

this is all to do with different timers on the Attiny than the Atmega chip but we don’t need to worry about it unless you want to change the library code (THAT IS SOME HARD STUFF DON’T CHANGE THE CODE) but there are some libraries or the same library just ported to the Attiny so the codes we write is the same as it is for the arduino. you can download the zip file here :

Just extract the files and put the IRremote file in the libraries folder in the the arduino folder the path should look like

C:\Users\(your user)\Documents\Arduino\libraries

you will also need to download this for the next step:…

Step 2: Fixing the final error

Hopefully if you try to upload a sketch utalising the IR library you should now be left with this error

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr25/crttn85.o:(.init9+0x2): relocation truncated to fit: R_AVR_13_PCREL against symbol `exit’ defined in .fini9 section in c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr25\libgcc.a(_exit.o)

But don’t worry if you don’t you may likely be using the wrong core so just skip to step 4 (Troubleshooting) and come back to this step.

if you have the error above you are going to need to extract the second download from the last step ( this step is quite easy just copy the hardware folder to the hardware folder in where you installed the arduino ide (IT IS NOT WHERE WE PUT THE IR LIBRARY FOLDER) it will be some where in your program files (x86) (or the version for your operating system and pc). The path for mine is:

C:\Program Files (x86)\Arduino\hardware

once you copy it it will ask you if you want to replace Id.exe (make sure its only Id.exe and nothing else) select replace and let it copy (it doesn’t affect the normal ide so once its there you don’t need to worry.

if you are using a mac read reply #4 on this thread:…

How to use the IR library with an attiny using Arduino circuit

Step 3: A bit of code

This step is about code that I used to first get this working it was code that i used on the arduino except different pin numbers due to the less amount of pins on the attiny85. however for this code you will need to use an arduino and the serial monitor just so you can find out the code the buttons use. all the code and can be found here :…


For more detail: How to use the IR library with an attiny using Arduino

This Post / Project can also be found using search terms:

  • attiny2313 atmega8 atmega328 rgb Bluetooth
  • IR remote library for arduino in instructable
  • attiny ir receiver pdf
  • attiny13 arduino ir

Leave a Comment

= 3 + 4

(Spamcheck Enabled)

Read previous post:
Teardown, Analysis and Repair of an Agilent E4407B ESA-E Spectrum Analyzer In this episode Shahriar takes a detailed look at an Agilent (Keysight) E4407B ESA-E Spectrum Analyzer. The instruments reports...

Scroll to top