Good evening,
To begin, I'm quite a beginner in writing codes. I'm trying to write something for a while now, but now I got stuck. I try to use a uno to receive ir signals from my lg magic remote ( tried for a second to decode it's 2.4ghz RF signals but that seems quite complicated as I can find on the forum), and use two buttons of it. One for lowering my tv from the ceiling for appr 6 seconds, then turning on (discrete on code), the other button to do the opposite. This works all fine, but I do not want the Arduino to respond to the on button a second time ( since it then activates my tv lift again to lower the tv even more (a not-lifetime-improving action for the lift:) ). So a sort of "only if button off pressed -> response to pressing the on button". I hope one of you can help me with this issue:) Below the code until now:
// Include IR Remote Library by Ken Shirriff
#include <IRremote.h>
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
// Define sensor pin
const int RECV_PIN = 4;
// Define integer to remember toggle state
int togglestate = 0;
// Define IR Receiver and Results Objects
IRrecv irrecv(RECV_PIN);
decode_results results;
// Create IR Send Object
IRsend irsend;
void setup(){
Serial.begin(9600);
// Transmitter is connected to Arduino Pin #10
mySwitch.enableTransmit(10);
// Enable the IR Receiver
irrecv.enableIRIn();
}
void loop(){
if (irrecv.decode(&results)){
switch(results.value){
case 0x9001019: //on and tv down
// Turn tv down for X Seconds
mySwitch.send(1208561, 24);
delay(3000);
mySwitch.send(1208561, 24);
irsend.sendNEC(0x20DF23DCU, 32);
delay(1000);
irrecv.enableIRIn(); // Start the receiver
break;
case 0x900BCB5: //off and tv up
mySwitch.send(1208562, 24);
delay(3000);
mySwitch.send(1208562, 24);
irsend.sendNEC(0x20DFA35CU, 32);
delay(1000);
irrecv.enableIRIn(); // Start the receiver
break;
}
irrecv.resume();
}
}