Gallax
Published

DIY - Radio Remote Controller Basics

A radio controller for general purposes, the RF24 can reach up to 100m.

BeginnerProtip1,373
DIY - Radio Remote Controller Basics

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×2
RF24L01 with Antenna
×2
Jumper wires (generic)
Jumper wires (generic)
×1
Analog joystick (Generic)
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1
Tactile Switch, Top Actuated
Tactile Switch, Top Actuated
×1
Resistor 1k ohm
Resistor 1k ohm
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Controller Breadboard

Receiver

RF24 Pinout

Code

Controller - Send

Arduino
// Controller send 

#include <nRF24L01.h>
#include <RF24.h>
#include <RF24_config.h>     // include these libraries
#include <SPI.h>

RF24 radio(9, 10);      // CE, CSN pins                  
const uint64_t pipe = 0xE8E8F0F0E1LL;    // create 64 bit pipe,

int data[10] = { "001", "002", "003", "004", "005" };   // create 5 piece data array, in 3 digit formats

const int J1xPin = A2;     
const int J1yPin = A1;      // set joystick pins, these are all analog pins. 
const int Jpush1 = A3;

const int B1Pin = 3;       // set button pin, digital 

const int Pot1Pin = A0;   // set potentiometer pin 



void setup() {
  
  Serial.begin(9600);        // begin serial, 9600 baud
  
  radio.begin();                     // start radio
  radio.setPALevel(RF24_PA_MAX);     // set power level to max 
  radio.openWritingPipe(pipe);       // open the WRITING pipe, this is the sender. 
  radio.setDataRate(RF24_250KBPS);   // Set data rate to 250 KBPS     
  radio.enableDynamicPayloads();     // enable dynamic payloads helps
  radio.stopListening();             // STOP listening, so you can send data.             
 
  pinMode(Jpush1, INPUT); 
  pinMode(B1Pin,  INPUT_PULLUP);   // set the buttons and potentiometer as inputs. 
  pinMode(Pot1Pin,  INPUT);

  
  }



void loop() {

  data[0] = map(analogRead(J1xPin), 0, 1023, 100, 200); 
  data[1] = map(analogRead(J1yPin), 0, 1023, 200, 100);      // define data, startiung with 0. I have also mapped them as data 
  data[2] = map(analogRead(Jpush1), 1023, 0, 0, 1);          
  
  data[3] = digitalRead(B1Pin);                              // read the button pin as data
  
  data[4] = analogRead(Pot1Pin);                             // read the potentiometer as data 

 
  radio.write(&data, sizeof(data));               // write all the data, the size of the data
   
   Serial.print("J1x: ");
  Serial.print( data[0]);               // Print the values, these will read 0 if the radio is not connected. 
  Serial.print("\t"); 
  
   Serial.print ("J1y: ");
  Serial.println(data[1]);
  Serial.print("\t");
  
   Serial.print ("Jpush1: ");
  Serial.print(data[2]);
  Serial.print("\t");

   Serial.print ("B1: ");
  Serial.print(data[3]);
  Serial.print("\t"); 
  
   Serial.print ("Pot1: ");
  Serial.print(data[4]);
  Serial.print("\t");

   
  delay(10);    // 10 second delay 
  
   }














   

Controller Receive

Arduino
// Controller RECEIVE 

#include <nRF24L01.h>
#include <RF24.h>
#include <RF24_config.h>     // include these libraries
#include <SPI.h>

RF24 radio(9, 10);      // CE, CSN pins                  
const uint64_t pipe = 0xE8E8F0F0E1LL;    // create 64 bit pipe,

int data[10] = { "001", "002", "003", "004", "005" };   // create 5 piece data array, in 3 digit formats


void setup() {
  
  Serial.begin(9600);        // begin serial, 9600 baud
  
  radio.begin();                     // start radio
  radio.setPALevel(RF24_PA_MAX);     // set power level to max 
  radio.openReadingPipe(1, pipe);       // open READING pipe 
  radio.setDataRate(RF24_250KBPS);   // Set data rate to 250 KBPS     
  radio.enableDynamicPayloads();     // enable dynamic payloads helps
  radio.StartListening();             // START listening, .             

  
  }



void loop() {

  radio.read(&data, sizeof(data));  // read all the data, the size of the data
   
   Serial.print("J1x: ");
  Serial.print( data[0]);     // Print the values, these will read 0 if the radio is not connected. 
  Serial.print("\t"); 
  
   Serial.print ("J1y: ");
  Serial.println(data[1]);
  Serial.print("\t");
  
   Serial.print ("Jpush1: ");
  Serial.print(data[2]);
  Serial.print("\t");

   Serial.print ("B1: ");
  Serial.print(data[3]);
  Serial.print("\t"); 
  
   Serial.print ("Pot1: ");
  Serial.print(data[4]);
  Serial.print("\t");

   
  delay(10); 
  
   }














   

Credits

Gallax
4 projects • 3 followers
Contact

Comments

Please log in or sign up to comment.