trying to get 3 relays to be controlled through a ir reciever connected to a arduino, but my code is flawed, it wont compile, and im probbaly doing it wrong anyway…
need the following hex codes recieved from the remote to do the following
801 - turn on relay one
802 - turn off relay one
803 - turn on relay two
804 -turn off relay two
805 - turn on relay three
806 - turn off relay threee
here is my code
// example 32.1 - IR receiver code repeater
// http://tronixstuff.com/tutorials > chapter 32
// based on code by Ken Shirriff - http://arcfn.com
#include <IRremote.h> // use the library
int receiver = 11; // pin 1 of IR receiver to Arduino digital pin 11
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results;
void setup()
{
Serial.begin(9600); // for serial monitor output
irrecv.enableIRIn(); // Start the receiver
pinMode(13, OUTPUT); // sets the digital pin as output
pinMode(4, OUTPUT); // sets the digital pin as output
pinMode(7, OUTPUT); // sets the digital pin as output
}
void loop()
{
if (irrecv.decode(&results)) // have we received an IR signal?
{
Serial.println(results.value, HEX); // display it on serial monitor in hexadecimal
irrecv.resume(); // receive the next value
} // Your loop can do other things while waiting for an IR command
int (results.value)=80;
if (irrecv.decode(&results))0)
{
/* Here we wait for the first byte of a two byte control sequence. Send A, B or C to control filterpump,boosterpump, light, or blower.
*/
(irrecv.decode(&results))
if (!have_control)
{
have_control=true;
control_relay=12;
else if (results.value=='801')
control_relay=13;
}
// We have the control byte, now lets look for 1 or 0
if (results.value=='801')
{
// Turn specified relay on
if (control_relay==13)
state_SpaLight=HIGH;
}
else if (results.value=='802')
{
// Turn specified relay off
if (control_relay==13)
state_SpaLight=LOW;
}
else if (serial_byte=='?')
{
// This is where we issue our actual pin state to the arduino digital pins
digitalWrite(13, state_SpaLight);
}
}
}
i seriously have no idea what im doing, someone do this for me… im going with hardware not software