This circuit is designed to serve as a drone controller, utilizing an Arduino Nano as the central processing unit. It features wireless communication capabilities through an NRF24L01 module, visual feedback via an OLED display, user input through two Adafruit Analog 2-Axis Joysticks and a potentiometer, and digital input from toggle switches. The circuit is powered by a 2x 18650 battery pack and incorporates resistors for voltage division and current limiting purposes.
Arduino Nano: A compact microcontroller board based on the ATmega328P, which provides a variety of digital and analog I/O pins.
NRF24L01: A 2.4GHz wireless transceiver module used for remote communication between the drone and the controller.
OLED 1.3" Display: A small screen that provides visual output, interfaced via the I2C protocol.
Adafruit Analog 2-Axis Joystick (x2): Joysticks that offer analog input from two axes and a digital input from an integrated switch.
Potentiometer: An adjustable resistor that provides analog input corresponding to its rotational position.
Toggle Switch (x3): Switches that provide digital input to the Arduino Nano.
Resistor (x2): Resistors with a value of 1000 Ohms, used for voltage division and limiting current.
2x 18650 Battery Pack: The power source for the circuit.
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH1106.h>
#define OLED_RESET -1
Adafruit_SH1106 display(OLED_RESET);
float vol = 0;
int input = 0;
int vdividerPin = A7;
const uint64_t pipeOut = 0xE8E8F0F0E1LL;
RF24 radio(10, 9); // select CE and CSN pins
struct MyData {
byte throttle;
byte yaw;
byte pitch;
byte roll;
byte AUX1;
byte AUX2;
};
MyData data;
unsigned long oledUpdateTime = 0;
const unsigned long oledUpdateInterval = 100;
void resetData()
{
data.throttle = 0;
data.yaw = 127;
data.pitch = 127;
data.roll = 127;
data.AUX1 = 0;
data.AUX2 = 0;
}
void setup()
{
radio.begin();
radio.setAutoAck(false);
radio.setDataRate(RF24_250KBPS);
radio.openWritingPipe(pipeOut);
resetData();
display.begin(SH1106_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(1);
display.setCursor(20,5);
display.println("Arduino Drone");
display.setCursor(15,19);
display.println("Transmitter By");
display.setCursor(0,33);
display.println("--> UnKnown <--");
display.setCursor(0,47);
display.println(">UnKnown & UnKnown<");
display.display();
delay(10000);
display.clearDisplay();
pinMode(vdividerPin, INPUT);
Serial.begin(9600);
pinMode(5, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
}
int mapJoystickValues(int val, int lower, int middle, int upper, bool reverse)
{
val = constrain(val, lower, upper);
if ( val < middle )
val = map(val, lower, middle, 0, 128);
else
val = map(val, middle, upper, 128, 255);
return ( reverse ? 255 - val : val );
}
void loop()
{
unsigned long currentMillis = millis();
if (currentMillis - oledUpdateTime >= oledUpdateInterval) {
updateOLED();
oledUpdateTime = currentMillis;
}
data.throttle = mapJoystickValues( analogRead(A3), 13, 524, 1015, true );
data.yaw = mapJoystickValues( analogRead(A1), 50, 505, 1020, true );
data.pitch = mapJoystickValues( analogRead(A2), 12, 544, 1021, true );
data.roll = mapJoystickValues( analogRead(A6), 34, 522, 1020, true );
data.AUX1 = digitalRead(5);
data.AUX2 = digitalRead(3);
radio.write(&data, sizeof(MyData));
}
void updateOLED() {
input = analogRead(vdividerPin);
vol = (input * 10.0) / 1024.0;
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(2);
display.setCursor(0,5);
display.println("Voltage: ");
display.setCursor(0,30);
display.print(vol);
display.print(" V");
display.setTextSize(1);
display.setCursor(0,55);
display.print("-> BY UnKnown <-");
display.display();
delay(100);
}
Circuit Documentation
Summary
This circuit is designed to control a drone using an Arduino Nano as the central processing unit. It includes an NRF24L01 module for wireless communication, an OLED display for user feedback, two Adafruit Analog 2-Axis Joysticks for user input, a potentiometer for additional analog input, and toggle switches for digital input. The circuit is powered by a 2x 18650 battery pack, and it