Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
mschindl
Published © GPL3+

The Pilot Wireless Remote Control

The Wireless Remote Control for Arduino! Control your projects from up to 1,100 meters away!

IntermediateProtip690
The Pilot Wireless Remote Control

Things used in this project

Hardware components

Analog joystick (Generic)
×1
nRF24 Module (Generic)
×1
LCD Screen 16 x 2
×1

Story

Read more

Custom parts and enclosures

3D Printed Case

The 3D printable case for the Pilot RC!

Schematics

schematic_9aA1vmIpMI.jpg

Code

Simple Transmit Code

Arduino
This is the code to transmit Wireless Information with the Arduino and the NRF24L01+ module. This code uses the RF24 Library.
/*  Simple Transmit Version 1.02
 *  Author: Schindler Electronics
 *  Data: 6/1/2019
 *  
 *  This code demonstrates how to use the NRF module to
 *  transmit simple data to another NRF module.
 *  
 *  Note: This code requires another Arduino receiving data
 *  from another NRF module using the Simple_Recieve Sketch
 *  
 *  Note: This code requires the use of the RF24 Library. 
 *  You can easily download this library in the Arduino Library Manager.
 *  
 *  Changes: The code now transmits the values of the joysticks rather
 *  than fixed values.
 */

#include <SPI.h>   //Comes with Arduino IDE
#include "RF24.h"  //Download and Install (See above)

#define  CE_PIN  7 //The pins to be used for CE and CSN
#define  CSN_PIN 8

RF24 radio(CE_PIN, CSN_PIN);

byte addresses[][6] = {"1Node", "2Node"}; //These will be the names of the "Pipes"

struct dataStruct {       //this is the NRF data. Max of 32 bytes 
  int Xposition;          //int     = 2 bytes
  int Yposition;          //double  = 4 bytes
  bool switchOn;          //boolean = 1 byte

  int X2position;       
  int Y2position;
  bool switch2On;         
} myData;                //This can be accessed in the form:  myData.Xposition  etc.


void setup() { 
  Serial.begin(115200);
  pinMode(5, OUTPUT);             //Set up the Joysticks
  pinMode(4, OUTPUT);
  digitalWrite(5, HIGH);
  digitalWrite(4, HIGH);
 
  radio.begin();                   //Initialize the nRF24L01 Radio
  radio.setChannel(108);           //Above most WiFi frequencies
  radio.setDataRate(RF24_250KBPS); //Fast enough.. Better range

  radio.setPALevel(RF24_PA_MIN);   //This allows it to be used with only USB power. Use of RF24_PA_MAX requires battery connection

  radio.openWritingPipe(addresses[0]);     //Open a writing "Pipe" to send data out
  radio.openReadingPipe(1, addresses[1]);  //Open a reading "Pipe" to receive data

  radio.stopListening();                   //Stop Listening so we can start transmitting data
  Serial.println("Set Up Complete");
}


void loop() { 
    //This is the values that will be transmitted in the myData Struct
    myData.Xposition = analogRead(A0);
    myData.Yposition = analogRead(A1);
    myData.switchOn  = digitalRead(5);
    
    myData.X2position = analogRead(A2);
    myData.Y2position = analogRead(A3);
    myData.switch2On  = digitalRead(4);

    radio.write(&myData, sizeof(myData), 1); //Transmit Data using the write command
    Serial.println("Sent");
    delay(10);
}

Simple Receive

Arduino
This is the code to receive wireless communication from the Arduino and the NRF24L01+ module.
/*  Simple Recieve Version 1.02
 *  Author: Schindler Electronics
 *  Data: 6/1/2019
 *  
 *  This code demonstrates how to use the NRF module to
 *  receive simple data from another NRF module.
 *  
 *  Note: This code requires another Arduino transmitting data
 *  from another NRF module using the Simple_Transmit Sketch
 *  
 *  Note: This code requires the use of the RF24 Library. 
 *  You can easily download this library in the Arduino Library Manager.
 */

#include <SPI.h>   //Comes with Arduino IDE
#include "RF24.h"  //Download and Install (See above)

#define  CE_PIN  7 //The pins to be used for CE and CSN
#define  CSN_PIN 8

RF24 radio(CE_PIN, CSN_PIN);

byte addresses[][6] = {"1Node", "2Node"}; //These will be the names of the "Pipes"

struct dataStruct {       //this is the NRF data. Max of 32 bytes 
  int Xposition;          //int     = 2 bytes
  int Yposition;          //double  = 4 bytes
  bool switchOn;          //boolean = 1 byte

  int X2position;       
  int Y2position;
  bool switch2On;         
} myData;                //This can be accessed in the form:  myData.Xposition  etc.

void setup() { 
  Serial.begin(115200);
  radio.begin();                   //Initialize the nRF24L01 Radio
  radio.setChannel(108);           //Above most WiFi frequencies (2.4Ghz + 0.108Ghz = 2.508Ghz)
  radio.setDataRate(RF24_250KBPS); //Fast enough.. Better range

  radio.setPALevel(RF24_PA_MIN);   //This allows it to be used with only USB power. Use of RF24_PA_MAX requires battery connection

  radio.openWritingPipe(addresses[1]);    //Open a writing "Pipe" to send data out
  radio.openReadingPipe(1, addresses[0]); //Open a reading "Pipe" to receive data

  radio.startListening();                 //Start listening for incoming data
}


void loop() {
  
  if (radio.available()) {      
    radio.read( &myData, sizeof(myData) );                //If the NRF receives data on a Pipe read the data
    Serial.print(myData.Xposition);  Serial.print("\t");  //Print the data received
    Serial.print(myData.Yposition);  Serial.print("\t");
    Serial.print(myData.switchOn);   Serial.print("\t");
    Serial.print(myData.X2position); Serial.print("\t");
    Serial.print(myData.Y2position); Serial.print("\t");
    Serial.print(myData.switch2On);  Serial.print("\t");
    Serial.println();
  }
  
}

Basic Joystick Code

Arduino
Learn how to read the signals coming from the on board analog joysticks.
/*  Joystick_Basic Version 1.01
 *  Author: Schindler Electronics
 *  Data: 5/23/2019
 *   
 *  This code reads the value of each joystick
 *  axis using the Analog Read function.
 *  
 *  Each value for the joystick range should from 0-1023.
 *  The push-buttons should read 0 when pushed and 1 when not pushed.
 *
 */

void setup() {
Serial.begin(115200);
pinMode(5, OUTPUT);    //Set the pins connected to the joystick button to an output
pinMode(4, OUTPUT);
digitalWrite(5, HIGH); //Set the pins to HIGH (5V). When the button is pressed it will pull the pin to ground (0V)
digitalWrite(4, HIGH);
}

void loop() {
 Serial.print("Joystick L: ");
 Serial.print(analogRead(A2)); //Read the Joystick value
 Serial.print("\t");
 Serial.print(analogRead(A3)); //Read the Joystick value
 Serial.print("\t");
 Serial.print(digitalRead(4)); //Read the Button value
 Serial.print("\t");
 
 Serial.print("Joystick R: "); //Read the Joystick value
 Serial.print(analogRead(A0));
 Serial.print("\t");
 Serial.print(analogRead(A1)); //Read the Joystick value
 Serial.print("\t");
 Serial.print(digitalRead(5)); //Read the Button value
 Serial.print("\t");
 
 Serial.println();
 delay(10);
}

Voltage Sensor Code

Arduino
Learn how to read battery voltage with an Arduino!
/*  Voltage Version 1.01
 *  Author: Schindler Electronics
 *  Data: 5/23/2019
 * 
 *  This code demostrates how to read the voltage
 *  applied to the Battery pins of the Pilot RC
 *  
 *  Note: This will display around 4.5 Volts when no battery is
 *  applied to the pins. This is because the pins are reading the
 *  voltage coming out of the 5V voltage regulator.
 */

float vPow = 5.0;   //constant for calculations (5V devices)
float r1 = 49900;   //Value of Resistor 1
float r2 = 10000;   //Value of Resistor 2
float v, v2, vAvg, rcV, drV;
int vNum;

void setup() { 
  Serial.begin(115200);
}


void loop() {
   v = (analogRead(A4) * vPow) / 1024.0; //Value of the voltage coming out of the voltage divider
   v2 = v / (r2 / (r1 + r2));            //Actual voltage applied to the voltage divider (Battery Voltage)
   vAvg += v2;                           //We want to average 100 readings of the battery voltage to achieve an accurate result
   vNum++;

  if (vNum == 100) {                     //Print the Voltage being read by the Pilot RC and reset the counters
    rcV = vAvg/100;
    Serial.print("Voltage: "); 
    Serial.println(rcV);
    vNum=0;
    vAvg=0;
  }
  
  delay(10);
}

Credits

mschindl

mschindl

0 projects • 0 followers

Comments