Communicate Arduino Uno with ATtiny85

Hello all,

I previously had an issue communicating IR signals to an Arduino Uno while using a NeoPixel strip. The only way to get around this was to use 2 microcontrollers.

Now I am thinking of using an ATtiny85 for this purpose.
It would work like this:

  • The ATtiny85 would read IR signals from an infrared receiver and send them to the Arduino. This way the Arduino Uno wouldn't have to decode the signals and mess up due to interrupts.
  • Then the Arduino would receive the IR signals and figure out what this means. The serial communication wouldn't have an issue with interrupts.

At least that's what I think. I am entirely new to using an ATtiny85 and would appreciate ANY help including how to code it, what programmer to use, how to communicate between the ATtiny85 and the Arduino, etc...

Thanks in advance!

Maybe this will help you getting started?

High-Low Tech – Programming an ATtiny w/ Arduino 1.6 (or 1.0) (

Follow the previous posts for information. It is similar to programming code for an UNO except the resources are more limited and you probably want to use the ISP for device programming. You could do the IR decode on the ATtiny85 and send a more meaningful command to the UNO.

I like the ATTiny85 and use it in its 8pin dip version. There are some things you need to be aware of though. Check out Dr. Azzy's github and the spec sheet for the attiny85 and you should be good. It doesnt have a built in serial port and one of the pins needs to be left for use as a reset. Dr. Azzys github shows you how to program the chip. I ended up using the 6 pin ISP header. I think it is worth learning to use the attiny because of its small size and its inexpensive.

Dr. Azzy is the author of the excellent ATTinyCore core. I tried several cores when starting with the tiny85 and the ATTinyCore is hands down the best. Use Serial, I2C or SPI to communicate with an Uno.

I will look into this.
How about the code?

Looks like this helps a lot.

Yes, I use his core also. Excellent info well documented. He put a lot of hours into that project.

How do I wire this up and code it?

Long ago, for SONY TV remote:

  IR remote control (Sony) detection for Arduino, M. Burnette
  Binary sketch size: 2,794 bytes (of a 8,192 byte maximum)

  ☺  20130103 MRB Modified for interface to Mega2560
      Europa codebase for menu system
  ☺  20121230 MRB Modified for Tiny85 Google Tiny library
      Tiny85 Internal RC 16MHz

  ☺  20121230 MRB modifications to adapt to numeric input, avoid dupes,
      and to generally "behave" consistently
  ☺  Used with Electronic Goldmine IR detector MIM 5383H4
  ☺  IR detector:
      Pin 1: To pin D4 on Arduino ATtiny85
      Pin 2: GND
      Pin 3: 5V through 33 Ohm resistor
  ☺  This is based on pmalmsten's code found on the Arduino forum from 2007:

// Pins 2/3 used for Software serial
int irPin     = 4;       //Sensor pin 1 wired to Arduino's pin D4
int statLED   = 0;       //Toggle the status LED every time Power is pressed
int start_bit = 2200;    //Start bit threshold (Microseconds)
int bin_1     = 1000;    //Binary 1 threshold (Microseconds)
int bin_0     = 400;     //Binary 0 threshold (Microseconds)

void setup() {
  pinMode(statLED, OUTPUT);
  digitalWrite(statLED, LOW);

  pinMode(irPin, INPUT);

  Serial.println("IR/Serial Initialized: ");

void loop() {
  int key = getIRKey();   //Fetch the key
  if(key != 0)            //Ignore keys that are zero
      case 128: Serial.print("1"); break;
      case 129: Serial.print("2"); break;
      case 130: Serial.print("3"); break;
      case 131: Serial.print("4"); break;
      case 132: Serial.print("5"); break;
      case 133: Serial.print("6"); break;
      case 134: Serial.print("7"); break;
      case 135: Serial.print("8"); break;
      case 136: Serial.print("9"); break;
      case 137: Serial.print("0"); break;
      case 144: Serial.print("A"); break;  // CH Up
      case 145: Serial.print("B"); break;  // CH Down
      case 146: Serial.print("C"); break;  // VOL Right
      case 147: Serial.print("D"); break;  // VOL Left
      case 148: Serial.print("E"); break;  // Mute
      case 165: Serial.print("F"); break;  // AV/TV
      case 149: Serial.print("P");         // Power == MENU ACTIVE
        //This toggles the statLED every time power button is hit
        if(digitalRead(statLED) != 1)
          digitalWrite(statLED, HIGH);
          digitalWrite(statLED, LOW);

      //default: Serial.println(key); // for inspection of keycode

    delay(400);    // avoid double key logging (adjustable)

int getIRKey() {
  int data[12];
  int i;

  while(pulseIn(irPin, LOW) < start_bit); //Wait for a start bit
  for(i = 0 ; i < 11 ; i++)
    data[i] = pulseIn(irPin, LOW);      //Start measuring bits, I only want low pulses
  for(i = 0 ; i < 11 ; i++)             //Parse them
    if(data[i] > bin_1)                 //is it a 1?
      data[i] = 1;
    else if(data[i] > bin_0)            //is it a 0?
      data[i] = 0;
      return -1;                        //Flag the data as invalid;  Return -1 on invalid data

  int result = 0;
  for(i = 0 ; i < 11 ; i++)             //Convert data bits to integer
    if(data[i] == 1) result |= (1<<i);

  return result;                        //Return key number

Please note, changes may be necessary to compile with newer IDE/core

Notes.h (603 Bytes)
Tiny85_IR_Code_Rec.ino (3.4 KB)

Thanks! I am now on vacation but I will soon buy an ATtiny85 and the programmer for it.


A dedicated UNO/mini and a ZIF socket may be more flexible.

Use the ISP sketch:

Arduino as ISP and Arduino Bootloaders | Arduino Documentation | Arduino Documentation

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