RF Reciever

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

Hi, Welcome to the forum.

Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code. It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

How did you get the numerical codes?

Tom... :)

Please learn to write C code first. This line contains 3 errors:

 if (value = 5592323);

It does an assignment instead of a comparison, does not use the result, and the following code is not separated into blocks. As incomplete hint:

  if (value == 5592323) {

Please edit your post to add code tags.