I'm having an issue using using the IRremote library with an ATTiny85.
I'm trying to write a sketch that turns on an LED when I press the power button on a remote control, and then turns it off when I press it again.
I know the IRremote library supports the ATTiny85, because it says that it the documentation. I thought that maybe that I was using the wrong pin, but even when I tried the other pins, they wouldn't work either. The pinout diagram on SparkFun says that pin 1 is capable of doing PWM, which is what I need for the IR receiver.
I'm thinking that maybe my wiring is wrong, or that it has something to do with the "Timers" column in the IRremote documentation that says "TINY0", under the ATTiny85 row. I'm not really sure what that means. Another possibility is that I'm not starting the IR receiver properly in the setup() method.
I haven't put a default in my case statement just yet
That would be the next obvious thing to do. Make it switch the led on.
That tests if it receiving anything from the IR remote and that your LED is wired correctly.
I just got this to work but there are many places it can go wrong so i thought I would share them.
Make sure you know the pins on your receiver. If you get them wrong you may or may not here the tiny pop of the receiver blowing out. After that it will never work again. I was using this IR receiver.
First watch this video as you will want to get software Serial working so you can see what IR signals are coming in.
Other people said you could use the adafruit trinket for the board, but I didn't try it.
In order to get the ATTINY 85 to receive the IR code from a remote you need to burn the bootloader at internal 16MHz. I guess that's the speed the remote is sending the signals at?
Then upload this code to the ATTINY 85. It will print out the IR values received using a neat little bit of code. The IR value is stored in byteVal. The advantage of using this code over including the IR library is that the IR library takes up most of the memory space on the ATTINY and this code does not.
#include <SoftwareSerial.h>
int pinData= 0;
unsigned long lengthHeader;
unsigned long bit;
int byteValue;
SoftwareSerial mySerial(3,4);
void setup()
{
Serial.begin(9600);
pinMode(pinData, INPUT);
}
void loop()
{
lengthHeader = pulseIn(pinData, LOW);
if(lengthHeader > 1500)
{
for(int i = 1; i <= 32; i++)
{
bit = pulseIn(pinData, HIGH);
if (i > 16 && i <= 24)
if(bit > 1000)
byteValue = byteValue + (1 << (i - 17));
}
}
Serial.println(byteValue);
byteValue=0;
delay(250);
}
I was trouble shooting this for a long time. Hopefully this helps someone else get through it faster. Here is a video that proves it can be done.
grif0210 said "In order to get the ATTINY 85 to receive the IR code from a remote you need to burn the bootloader at internal 16MHz. I guess that's the speed the remote is sending the signals at?"
How did you burn the bootloader? I'm just starting with ATtiny85, and I also, have a camera remote that works with uno or nano, but not the attiny85.
Here is a lightweight IR library for remote control devices which use the NEC protocol (quite common for cheap devices). It can work on an ATtiny at 8MHz (I tested it with an ATtiny841) and leaves some resources for the sketch. It does not use a hardware timer.
I noticed the "working" code example you posted above has a tiny error preventing it from uploading to ATTiny85. At the top, you declare the variable mySerial, which is perfectly fine, but then invoke Serial.begin(9600). Serial.begin(9600) should be mySerial.begin(9600).
Also, I couldn't successfully print out IR signal values with this code. It uploads, then prints zero (0) ad infinitum, with presses on my Sony remote momentarily increasing the frequency of printed zeros.
I've successfully created a "universal" remote a few years ago as well as an IR decoder, but cannot
remember how the heck I did it.