Hi there,
I am trying to create a simple sketch to switch things using an IR remote. It works, but I have to press a button several times to get a response and I think this has to do with the HEX code sent out by the remote. (found that with a IR reader)
The code sent shows: FD9A65 FFFFFF FFFFFF FFFFFF etc.
The sketch is meant for an ATTiny85, and like mentioned, it works, but not satisfactory. I think that is caused by the “overwhelming” amount of FFFFFF’s that follow the intended HEX.
So, how do I filter out/ignore those FFFFFF’s in the sketch? Or add something to the sketch to make it recognize the active HEX PLUS one or two FFFFFF’s
(A second question that has come up; why is there no list of commands that one can use, or something like that in the library?)
The sketch:
#include <IRremote.h>
int RECV_PIN = 2;
IRrecv irrecv(RECV_PIN);
decode_results results;
int x;
#define code0 0xFD9A65 //Button Power/Standby
#define code1 0xFD1AE5 //Button Subtitle
#define code2 0xFD18E7 //Button Language
#define code3 0xFD9867 //Button Open/Close
#define code4 0xFDB24D //Button Angle
void setup()
{
irrecv.enableIRIn();
pinMode(0,OUTPUT);
pinMode(1,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
}
void loop()
{
if (irrecv.decode(&results))
{
int x = (results.value);
switch(x) {
case code1:
digitalWrite(0,HIGH);
break;
case code2:
digitalWrite(1,HIGH);
break;
case code3:
digitalWrite(3,HIGH);
break;
case code4:
digitalWrite(4,HIGH);
break;
case code0:
digitalWrite(0,LOW);
digitalWrite(1,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
break;
}
irrecv.resume(); // Receive the next value
}}
Program uses 76% of memory of the ATTiny. Settings for loading the sketch were:
Clock 8 Mhz internal, BOD disabled, Arduino as SPI.