Arnov SharmaElektro Punkz
Published © GPL3+

NRF24 Based Drone Setup

Just another "DRONE PROJECT" with a custom Transmitter and Reciever setup based on Arduino Nano and NRF24L01 Module

BeginnerFull instructions provided2 hours7,711

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
drone kit
×1
JLCPCB Customized PCB
JLCPCB Customized PCB
×1
bldc motor
×4
ESC
×4
UTSOURCE Electronic Parts
UTSOURCE Electronic Parts
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

TRANSMITTER

RECEIVER

Code

flight_controller_Reciever

C/C++
#include <Servo.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define LED 3
#define MOT1 3
#define MOT2 5
#define MOT3 6
#define MOT4 9

int speed = 75;
const byte addresses[][6] = {"000001", "000002"};
uint8_t state = LOW;
uint8_t val_x = 0x00, val_y = 0x00;
RF24 radio(7, 8);

Servo ser1, ser2, ser3, ser4;

void setup() {
	ser1.attach(MOT1);
	ser2.attach(MOT2);
	ser3.attach(MOT3);
	ser4.attach(MOT4);

    radio.begin();
    radio.openWritingPipe(addresses[0]);
    radio.openReadingPipe(1, addresses[1]);
    radio.setPALevel(RF24_PA_MIN);
	radio.startListening();
}

void loop() {
	while(radio.available()) {
		radio.read(&val_x, sizeof(val_x));
		_delay_ms(1);
		ser1.write(val_x);
		ser2.write(val_x);
		ser3.write(val_x);
		ser4.write(val_x);
	}
}

Flight_controller_transmitter

C/C++
#include <SPI.h>
#include <RF24.h>
#include <nRF24L01.h>

#define POTX A1
#define POTY A0

RF24 radio(7, 8); // CE, CSN

const byte addresses[][6] = {"000001", "000002"};
int led_switch = LOW;

void setup() {
	pinMode(POTX, INPUT);
	pinMode(POTY, INPUT);
	Serial.begin(9600);

    radio.begin();
    radio.openWritingPipe(addresses[1]);
    radio.openReadingPipe(1, addresses[0]);
    radio.setPALevel(RF24_PA_MIN);
    radio.stopListening();
}

void loop() {
	int angle_x = map(analogRead(POTX), 0, 1023, 0, 180);
	radio.write(&angle_x, sizeof(angle_x));
	Serial.print("Angle X : ");
	Serial.println(angle_x);
	delayMicroseconds(1);
}

Credits

Arnov Sharma

Arnov Sharma

306 projects • 306 followers
Just your average MAKER
Elektro Punkz

Elektro Punkz

2 projects • 9 followers
"EleKtroPunkz Research Society"

Comments