Here is the full code if anyone is trying to do what I did at some stage. You will need to replace the Two values (or more, just copy and past new 'else if' statements. the values will be produced by this code as 'Received Other Value' Serial Prints.
As mentioned in the code, this is a Modifed simple receiving code created by the awesome people at:
/*
Modifed simple receiving code created by the awesome people at:
http://code.google.com/p/rc-switch/
*/
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
void setup() {
Serial.begin(9600);
mySwitch.enableReceive(0); // Receiver on inerrupt 0 => that is pin #2
pinMode(4, OUTPUT); // Location of Mosfet
pinMode(6, OUTPUT); // Operation Indicator LED (optional)
}
void loop() {
if (mySwitch.available()) {
unsigned long value = mySwitch.getReceivedValue();
if (value == 7419184) // This is the value received when button one on TX is pushed
{
Serial.print("Mosfet ON - Value = "); // This and the next three lines are for debug and testing purposes
Serial.print(mySwitch.getReceivedValue() );
Serial.print(" /// ");
Serial.println("");
digitalWrite(4, HIGH); // set the Mosfet On
digitalWrite(6, HIGH); // set the LED on
delay(5000); // wait for 5 seconds
digitalWrite(4, LOW); // set the Mosfet Off
digitalWrite(6, LOW); // set the LED Off
}
else if (value == 7419139) // This is the value received when button two on TX is pushed
{
Serial.print("Mosfet OFF - Value = "); // This and the next two lines are for debug and testing purposes
Serial.print(mySwitch.getReceivedValue() );
Serial.print(" /// ");
Serial.println("");
digitalWrite(4, LOW); // set the Mosfet Off
digitalWrite(6, LOW); // set the LED Off
}
else // If neither of the above two values are received it activates this message.
{
Serial.print("Received Other Value:"); // This and the next two lines are for debug and testing purposes
Serial.print(mySwitch.getReceivedValue() );
Serial.print(" /// ");
Serial.println("");
}
mySwitch.resetAvailable();
}
}