Here you can see the circuit diagrams and transmitter and receiver code for the previously made transmitter and receiver. You can click on the link below to check it.

TRANSMITTER          RECEIVER

Transmitter and receiver circuit diagram

Here is the circuit diagram for the transmitter



Here is the circuit diagram for the receiver






Coding for transmitter and receiver

Transmitter code

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

const uint64_t my_radio_pipe = 0xE8E8F0F0E1LL; //Note that this should be the same for the receiver

RF24 radio(9, 10);  //Set CE and CSN pins here


struct Data_to_be_sent {
  byte ch1;
  byte ch2;
  byte ch3;
  byte ch4;
  byte ch5;
  byte ch6;
  byte ch7;
};


DataToBeSent sent_data;

void setup()
{
  radio.begin();
  radio.setAutoAck(false);
  radio.setDataRate(RF24_250KBPS);
  radio.openWritingPipe(my_radio_pipe);

  //Reset each channel value
  sent_data.ch1 = 127;
  sent_data.ch2 = 127;
  sent_data.ch3 = 127;
  sent_data.ch4 = 127;
  sent_data.ch5 = 0;
  sent_data.ch6 = 0;
  sent_data.ch7 = 0;
}

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


void loop()
{
  //Create the PWM Signal
  sent_data.ch1 = map( analogRead(A0), 0, 1024, 0, 255);
  sent_data.ch2 = map( analogRead(A1), 0, 1024, 0, 255);
  sent_data.ch3 = map( analogRead(A2), 0, 1024, 0, 255);
  sent_data.ch4 = map( analogRead(A3), 0, 1024, 0, 255);
  sent_data.ch5 = digitalRead(2);
  sent_data.ch6 = digitalRead(3);

  radio.write(&sent_data, sizeof(DataToBeSent));
}


Receiver code

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Servo.h>

const uint64_t pipeIn = 0xE8E8F0F0E1LL; //same as in the transmitter

RF24 radio(7, 8); 
Servo ESC,ESC1,ESC2,ESC3;     // create servo object to control the ESC
int PWM,PWM1,PWM2,PWM3;  // value from the analog pin

//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;
byte AUX1;
byte AUX2;
};

MyData data;

void resetData()
{
//We define the initial value of each data input
data.throttle = 0;
data.yaw = 127;
data.pitch = 127;
data.roll = 127;
data.AUX1 = 0;
data.AUX2 = 0;

}

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

void setup()
{
Serial.begin(9600); 
//You should always have the same speed selected in the serial monitor

ESC.attach(3,1000,2000); // (pin, min pulse width, max pulse width in microseconds) 
ESC1.attach(5,1000,2000);
ESC2.attach(6,1000,2000);
ESC3.attach(9,1000,2000);

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();
}
  
  PWM = map(data.throttle, 0, 255, 0, 180);
  PWM1 = map(data.yaw, 0, 255, 0, 180);
  PWM2 = map(data.pitch, 0, 255, 0, 180);
  PWM3 = map(data.roll, 0, 255, 0, 180);
  
  ESC.write(PWM);    // Send the signal to the ESC
  ESC1.write(PWM1);
  ESC2.write(PWM2);
  ESC3.write(PWM3);
  

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("    ");
Serial.print("Aux1: ");     Serial.print(data.AUX1);      Serial.print("\n");
Serial.print("Aux2: ");     Serial.print(data.AUX2);      Serial.print("\n");

}

YouTube video



Thanks, guys. Make sure to like and subscribe to my YouTube Channel.