Hi
Does anyone know if it is possible to use an RF receiver on a Arduino Mega which has an 8 channel relay board attached and control the relays via a button press from a rf remote. I have the decimal codes from the remote and tried a bit of code but cant seem to get it working. Any help appreciated.
#include <Arduino.h>
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
void setup() {
Serial.begin(9600);// Start serial comunication at baud=9600
mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #2
void loop()
{
if (mySwitch.available()) {
int value = mySwitch.getReceivedValue();
// Raise Lifters 1 & 2 /////////////////////////////////////////////////////// code - button 1
if (value = 5592323);
digitalWrite(RELAY1, LOW);
digitalWrite(RELAY2, HIGH);//Activate the relay one direction, they must be different to move the lifter
digitalWrite(RELAY3, LOW);
digitalWrite(RELAY4, HIGH);//Activate the relay the other direction, they must be different to move the lifter
// Stop Lifters 1 & 2 ////////////////////////////////////////////////////////// code - button 2
if (value = 5592332);
digitalWrite(RELAY1, HIGH);
digitalWrite(RELAY2, HIGH);//Activate the relay one direction, they must be different to move the lifter
digitalWrite(RELAY3, HIGH);
digitalWrite(RELAY4, HIGH);//Activate the relay the other direction, they must be different to move the lifter
// Lower Lifters 1 & 2 /////////////////////////////////////////////////////////// code - button 3
if (value = 5592335);
digitalWrite(RELAY1, HIGH);
digitalWrite(RELAY2, LOW);//Activate the relay one direction, they must be different to move the lifter
digitalWrite(RELAY3, HIGH);
digitalWrite(RELAY4, LOW);//Activate the relay the other direction, they must be different to move the lifter
// Stop Lifters 1 & 2 ////////////////////////////////////////////////////////// code - button 4
if (value = 5592368);
digitalWrite(RELAY1, HIGH);
digitalWrite(RELAY2, HIGH);//Activate the relay one direction, they must be different to move the lifter
digitalWrite(RELAY3, HIGH);
digitalWrite(RELAY4, HIGH);//Activate the relay the other direction, they must be different to move the lifter
// Raise Lifters 3 & 4 For Right To Left Putt /////////////////////////////////// code - button 5
if (value = 5592371);
digitalWrite(RELAY5, LOW);
digitalWrite(RELAY6, HIGH);//Activate the relay one direction, they must be different to move the lifter
digitalWrite(RELAY7, LOW);
digitalWrite(RELAY8, HIGH);//Activate the relay the other direction, they must be different to move the lifter
// Stop Lifters 3 & 4 ////////////////////////////////////////////////////////// code - button 6
if (value = 5592380);
digitalWrite(RELAY5, HIGH);
digitalWrite(RELAY6, HIGH);//Activate the relay one direction, they must be different to move the lifter
digitalWrite(RELAY7, HIGH);
digitalWrite(RELAY8, HIGH);//Activate the relay the other direction, they must be different to move the lifter
// Lower Lifters 3 & 4 ////////////////////////////////////////////////////////// code - button 7
if (value = 5592383);
digitalWrite(RELAY5, HIGH);
digitalWrite(RELAY6, LOW);//Activate the relay one direction, they must be different to move the lifter
digitalWrite(RELAY7, HIGH);
digitalWrite(RELAY8, LOW);//Activate the relay the other direction, they must be different to move the lifter
// Stop Lifters 3 & 4 ////////////////////////////////////////////////////////// code - button 8
if (value = 5592512);
digitalWrite(RELAY5, HIGH);
digitalWrite(RELAY6, HIGH);//Activate the relay one direction, they must be different to move the lifter
digitalWrite(RELAY7, HIGH);
digitalWrite(RELAY8, HIGH);//Activate the relay the other direction, they must be different to move the lifter
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
Thanks
Andy