4-Button RF Control Programing

I'm very new to coding and using the Arduino Uno. I purchased the Keyfob 4-Button RF remote Control - 315 MHz along with the Simple RF M4 Receiver - 315 MHz Momentary Type from Adafruit.

I am planning on controlling a push pull solenoid with the key fob. With each button doing of the key fob doing something different (ie. button A causes the solenoid to push, Button B causes the solenoid to Pull, etc.).

I have searched for about 2 weeks now on how to write a code to use the Keyfob and receiver, as well as how to write a code so the buttons do different actions. This is the only thing I have found that is using the keyfob and receiver: Source Code | Making Adabot: Part 2 | Adafruit Learning System however I am still confused on what commands to use to use the buttons to control the push pull solenoid, and what commands to use to make all 4 buttons do something different. Could anyone help me out with what commands to use?

mill510:
I'm very new to coding and using the Arduino Uno. I purchased the Keyfob 4-Button RF remote Control - 315 MHz along with the Simple RF M4 Receiver - 315 MHz Momentary Type from Adafruit.

I am planning on controlling a push pull solenoid with the key fob. With each button doing of the key fob doing something different (ie. button A causes the solenoid to push, Button B causes the solenoid to Pull, etc.).

I have searched for about 2 weeks now on how to write a code to use the Keyfob and receiver, as well as how to write a code so the buttons do different actions. This is the only thing I have found that is using the keyfob and receiver: Source Code | Making Adabot: Part 2 | Adafruit Learning System however I am still confused on what commands to use to use the buttons to control the push pull solenoid, and what commands to use to make all 4 buttons do something different. Could anyone help me out with what commands to use?

Welcome to the Arduino forum.
That is quite a project for someone new to coding and new to the Arduino. Are you also new to anything electronic, as well?
At this point, forget about commands, etc. and concentrate on getting the receiver to work with the Arduino and proving that you can detect when the FOB sends anything.
As a hint, the FOB will send a different code for each push button and will continue to send that code as long as that button is pressed. But first things first, get the receiver working!
Good luck,
Paul

looking at the video on the link is looks pretty straight forward if you know what your doing of course! :wink:

for example, if you wire you RF receiver as follow:

You could write something like this for your code:
(here I've assumed that both selenoid terminals are connected to the arduino)

(Compiles, NOT tested!)

//define your RF inputs
#define RF_D0 10
#define RF_D1 11
#define RF_D2 12
#define RF_D3 13

//define your outputs
#define solenoid_push 4
#define solenoid_pull 5
#define D2_OUT 6
#define D3_OUT 7

void setup () {
  //initialise arduino inputs
  pinMode(RF_D0, INPUT_PULLUP);
  pinMode(RF_D1, INPUT_PULLUP);
  pinMode(RF_D2, INPUT_PULLUP);
  pinMode(RF_D3, INPUT_PULLUP);

  //initialise arduino outputs
  pinMode(solenoid_push, OUTPUT);
  digitalWrite(solenoid_push, LOW); //set output to LOW
  pinMode(solenoid_pull, OUTPUT);
  digitalWrite(solenoid_pull, LOW); //set output to LOW
  pinMode(D2_OUT, OUTPUT);
  digitalWrite(D2_OUT, LOW); //set output to LOW
  pinMode(D3_OUT, OUTPUT);
  digitalWrite(D3_OUT, LOW); //set output to LOW

}

void loop() {

  //loop through the 4 inputs and set the outputs accordingly

  //dO controls output 'solenoid_push'
  if (digitalRead(RF_D0) == LOW) {
    digitalWrite(solenoid_push, HIGH);
    digitalWrite(solenoid_pull, LOW);
  }
  else {
    digitalWrite(solenoid_push, LOW);
  }

  //d1 controls output 'solenoid_pull'
  if (digitalRead(RF_D1) == LOW) {
    digitalWrite(solenoid_pull, HIGH);
    digitalWrite(solenoid_push, LOW);
  }
  else {
    digitalWrite(solenoid_pull, LOW);
  }

  //d2 controls output 'RF_D2'
  if (digitalRead(RF_D2) == LOW) {
    digitalWrite(D2_OUT, HIGH);
  }
  else {
    digitalWrite(D2_OUT, LOW);
  }


  //d3 controls output 'RF_D2'
  if (digitalRead(RF_D3) == LOW) {
    digitalWrite(D3_OUT, HIGH);
  }
  else {
    digitalWrite(D3_OUT, LOW);
  }

  delay(100); //arbitrary delay to slow the loop a little

}

hope that helps...

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.