ATtiny84 IR Receiver Help!

Hello, I have spent 10 hours trying to get an IR receiver to work on my ATtiny84. I have tried three libraries (IRLremote, IRsmallDecoder, IRremote (too large for my project), and can't switch on an LED (base case).

Basic information:
1: All code works on Arduino Uno- so the code is not the issue (necessarily). It compiles on ATtiny84.
2: I can get other code to run on the ATtiny using Arduino as ISP- so it is not a chip problem.
3: I can't debug using serial, despite hours trying to figure out how to print serial output and watching videos. Instead, I chose to switch on an LED.
4: I have tried to map EVERY pin to IR receiver- no luck

Below is my code that for two attempts. I am desperate at this point- I have tried everything.

// IRLremote EXAMPLE
// include PinChangeInterrupt library* BEFORE IRLremote to acces more pins if needed
#include "PinChangeInterrupt.h"

#include "IRLremote.h"

// Choose a valid PinInterrupt or PinChangeInterrupt* pin of your Arduino board
#define pinIR 2

// Choose the IR protocol of your remote. See the other example for this.
CNec IRLremote;

void setup()
{  pinMode(1, OUTPUT);
 
  // Start reading the remote. PinInterrupt or PinChangeInterrupt* will automatically be selected
  if (!IRLremote.begin(pinIR)){

  }

}
void loop()
{
  if (IRLremote.available())
  {
    digitalWrite(1, HIGH);
    delay(500);
    digitalWrite(1, LOW);
    delay(500);
    auto data = IRLremote.read();

  }
 
}

Below is my code for IRsmallDecoder

#define IR_SMALLD_NEC         //1st: define which protocol to use:
#include <IRsmallDecoder.h>   //2nd: include the library;
IRsmallDecoder irDecoder(1);  //3rd: create one decoder object with the correct digital pin;
irSmallD_t irData;            //4th: declare one decoder data structure;

void setup() {
pinMode(1, OUTPUT);
}

void loop() {
  if (irDecoder.dataAvailable(irData)) {  //5th: if the decoder has some new data available,
    digitalWrite(1, HIGH);
    delay(500);
    digitalWrite(1, LOW);
    delay(500);
  }
}

If anyone has any functional code for ATtiny84 that they can share, I would be grateful. I need code that take up less memory than IRremote.

THANKS!

Where have you set the IRpin as an input?

This simulation might be "sim only" code (the "remote" values are, at least). I have lost the decode source, but it looks the same as many other non-library decode "getIrKey()" functions. I think it was wokwi.

Yep, that code sets the IRPin as an input - OP's does not.

The Arduino doesn't know if it is supposed to output , input, or float the IRPin at the moment!

1 Like

If you are using the NEC protocol, then you can try this: Lightweight Arduino IR library for NEC remote control devices
Get the example sketch working before trying to incorporate it in your code.

Edit. The external interrupt pin on an ATtiny84 (PB2) is pin 8 with the default clockwise numbering system of the @Drazzy core: ATTinyCore/avr/extras/ATtiny_x4.md at v2.0.0-devThis-is-the-head-submit-PRs-against-this · SpenceKonde/ATTinyCore · GitHub

1 Like

Post the the whole sketch that works for Arduino UNO. Also, post the pictures of IR-Receiver and IR-Transmitter.

1 Like

Use IRremote#s TinyReceicver or SimpleReceiver example.
Pinning is ATtiny84 |PB2 |PA4 |PA3 ATTinyCore

1 Like

I will ASAP. On vacation

I believe that is declared here 'irSmallD_t irData; ' and 'CNec IRLremote;'

The post above is the same code for both Arduino and ATtiny84. The code executes on the Uno. the IR remote/Receiver are from here IR receiver

I don't know if that is correct, particularly given that the same code executes on Uno but not ATtiny84. The documentation for both libraries does not require, but I will try anyways and let you know

According to the code in #1: if pin 1 is the input for the IR detector

IRsmallDecoder irDecoder(1); //3rd: create one decoder object with the correct digital pin; 

then it cannot be the output to drive a LED

pinMode(1, OUTPUT);

A pin can be an input or an output, but not both at the same time. :wink:

1 Like

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