I have an unusual project. I'm using a device only capable of transmitting one code over IR. All attempts get it firing more than one have been unsuccessful, which is a problem because i need to have it both push and pull an actuator. However, the receiver side may be my way in. It's a simple motor driver board connected to a UNO.
So my goal is to have this receiver take the single code and do one thing, then on the second press, the other.
Here's the code. Note: its for a multi button remote. Trying to modify it to work with one.
#include <IRremote.h>
#define irPin 3
IRrecv irrecv(irPin);
decode_results results;
#define in1 5
#define in2 6
const int buzzer = 9;
#define buzzer 9
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn();
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(buzzer, OUTPUT); // Unused buzzer
}
void loop()
{
if (irrecv.decode(&results))
{
Serial.print(results.value, HEX);
Serial.print(" - ");
Serial.println(results.value);
switch (results.value)
{
case 50161: //Actuator PULL
digitalWrite(in1,HIGH);
delay(500);
digitalWrite(in1,LOW);
delay(250);
break;
case 50174: //Actuator PUSH
digitalWrite(in2,HIGH);
delay(500);
digitalWrite(in2,LOW);
delay(250);
break;
}
irrecv.resume();
}
}
This isn't my code btw. I just hacked it a little.Preformatted text