Thanks in advance for help and advice!
For a few days I have tried to crack the code…I have done research here and other places to figure it out.
I need for the PIN to stay HIGH when I press and hold the remote button. When the button isnt pressed, the PIN goes LOW. The remote I am using does produce a “repeat” code, after the initial code is given, if the button is held. I have been successfully able to code so that the initial code is always being read. The trouble I am having is being able to use the remote buttons as a momentary switch. If the button is held, PIN is high. If button isn’t pressed or held, button is LOW. I am only able to get it act like a latching button. Any help would be greatly appreciated!
Matt
#include <IRremote.h> // Library from "github.com/shirriff/Arduino-IRremote"
int RECV_PIN = 11; //Pin of the out leg of the 38kHz demodulating Infrared Receiver Module
int output1 = 5; // LED connected to pin
int output2 = 6; // LED connected to pin
int output3 = 9; // LED connected to pin
const int code1 = 0x10EFF807; //Remote code for button "A" on remote
const int code2 = 0x10EF7887; //Remote code for button "B" on remote
const int code3 = 0x10EF58A7; //Remote code for button "C" on remote
IRrecv irrecv(RECV_PIN);
decode_results results;
int lastCode = 0; // This keeps track of the last code RX'd
void setup()
{
Serial.begin(9600); //
irrecv.enableIRIn(); //
pinMode(output1, OUTPUT);
pinMode(output2, OUTPUT);
pinMode(output3, OUTPUT);
}
void loop() {
if (irrecv.decode(&results))
{
uint16_t resultCode = (results.value & 0xFFFF);
if (resultCode == 0xFFFF)
resultCode = lastCode;
else
lastCode = resultCode;
if (resultCode == code1) {
digitalWrite(output1, HIGH);
} else {
digitalWrite(output1, LOW);
}
Serial.println(resultCode);
irrecv.resume(); // Receive the next value
}
}