English
EspaƱol
yt_link
insta_link
fb_link
twitter_link
ADVERTISERS
PCBWay Ad




AFFILATE










Gearbest SG - 700 Satellite Navigation Foldable RC Drone Quadcopter - WHITE 720P WIFI FPV CAMERA
SG - 700 Satellite Navigation Foldable RC Drone Quadcopter - WHITE 720P WIFI FPV CAMERA only $46.99

Gearbest Xiaomi AMAZFIT Heart Rate Smartwatch - BLACK INTERNATIONAL VERSION
Xiaomi AMAZFIT Heart Rate Smartwatch - BLACK INTERNATIONAL VERSION only $89.99

Gearbest FeiLun FT011 2.4GHz Brushless RC Racing Boat - BLACK AND WHITE AND RED
FeiLun FT011 2.4GHz Brushless RC Racing Boat - BLACK AND WHITE AND RED only $96.99


Receiving test code for the transmitter



You can download the NRF24 library here

To install it we just go to Sketch -> Include library and we open the .zip file that we've just downloaded.



Code!

Receiving test code!


/* Test code for the Radio control transmitter
 *  Install the NRF24 library to your IDE
 * Upload this code to the Arduino UNO
 * Connect a NRF24 module to it:
 
    Module // Arduino UNO
    
    GND    ->   GND
    Vcc    ->   3.3V
    CE     ->   D9
    CSN    ->   D10
    CLK    ->   D13
    MOSI   ->   D11
    MISO   ->   D12

This code should print the received values to the serial monitor
Please, like share and subscribe : https://www.youtube.com/c/ELECTRONOOBS
*/

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
const uint64_t pipeIn = 0xE8E8F0F0E1LL; //Remember that this code is the same as in the transmitter

RF24 radio(9, 10); 

//We could use up to 32 channels
struct MyData {
byte throttle; //We define each byte of data input, in this case just 6 channels
byte yaw;
byte pitch;
byte roll;
};

MyData data;

void resetData()
{
//We define the inicial value of each data input
//3 potenciometers will be in the middle position so 127 is the middle from 254
data.throttle = 0;
data.yaw = 127;
data.pitch = 127;
data.roll = 127;
}

/**************************************************/

void setup()
{
Serial.begin(250000); //Set the speed to 9600 bauds if you want.
//You should always have the same speed selected in the serial monitor
resetData();
radio.begin();
radio.setAutoAck(false);
radio.setDataRate(RF24_250KBPS);

radio.openReadingPipe(1,pipeIn);
//we start the radio comunication
radio.startListening();

}

/**************************************************/

unsigned long lastRecvTime = 0;

void recvData()
{
while ( radio.available() ) {
radio.read(&data, sizeof(MyData));
lastRecvTime = millis(); //here we receive the data
}
}

/**************************************************/

void loop()
{
recvData();
unsigned long now = millis();
//Here we check if we've lost signal, if we did we reset the values 
if ( now - lastRecvTime > 1000 ) {
// Signal lost?
resetData();
}

Serial.print("Throttle: "); Serial.print(data.throttle);  Serial.print("    ");
Serial.print("Yaw: ");      Serial.print(data.yaw);       Serial.print("    ");
Serial.print("Pitch: ");    Serial.print(data.pitch);     Serial.print("    ");
Serial.print("Roll: ");     Serial.print(data.roll);      Serial.print("\n");


}

/**************************************************/


Now in order to test if the transmitter works well download the next code below and upload it to another arduino. Connect the NRF24 module to this second arduino in the same way as the transmitter. Power up the transmitter and open the serial monitor of the arduino IDE. This seconde test code should print on your monitor the received values. If the values are not in the range that you whant just use the "mapJoystickValues" function in the transmitter code to change the range.


Download the Receiving test sketch here