Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino Nano Controlled NRF24L01 Wireless Joystick

View and Edit Project In Cirkit DesignerImage of Arduino Nano Controlled NRF24L01 Wireless Joystick

Circuit Documentation

Summary

This circuit is designed to control a 4-channel transmitter using an Arduino Nano as the central processing unit. It interfaces with an NRF24L01 module for wireless communication and two KY-023 Dual Axis Joystick Modules for user input. A Lipo Battery provides power to the system, and an Electrolytic Capacitor is used for voltage smoothing. The Arduino Nano reads the joystick positions and transmits the data wirelessly via the NRF24L01 module.

Component List

Arduino Nano

Electrolytic Capacitor

NRF24L01

KY-023 Dual Axis Joystick Module (x2)

Lipo Battery

Wiring Details

Arduino Nano

Electrolytic Capacitor

NRF24L01

KY-023 Dual Axis Joystick Module

Lipo Battery

Documented Code

// 4 Channel Transmitter | 4 Kanal Verici

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

const uint64_t pipeOut = 0xE9E8F0F0E1LL;   //IMPORTANT: The same as in the receiver 0xE9E8F0F0E1LL | Bu adres alıcı ile aynı olmalı
RF24 radio(7, 8); // select CE,CSN pin | CE ve CSN pinlerin seçimi

struct Signal {
  byte throttle;
  byte pitch;
  byte roll;
  byte yaw;
};

Signal data;

void ResetData() 
{
  data.throttle = 127; // Motor Stop (254/2=127)| Motor Kapalı (Signal lost position | sinyal kesildiğindeki pozisyon)
  data.pitch = 127; // Center | Merkez (Signal lost position | sinyal kesildiğindeki pozisyon)
  data.roll = 127; // Center | merkez (Signal lost position | sinyal kesildiğindeki pozisyon)
  data.yaw = 127; // Center | merkez (Signal lost position | sinyal kesildiğindeki pozisyon)
}

void setup()
{
  //Start everything up

  radio.begin();
  radio.openWritingPipe(pipeOut);
  radio.stopListening(); //start the radio comunication for Transmitter | Verici olarak sinyal iletişimi başlatılıyor
  ResetData();
}

// Joystick center and its borders | Joystick merkez ve sınırları

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()
{
  // Control Stick Calibration | Kumanda Kol Kalibrasyonları
  // Setting may be required for the correct values of the control levers. | Kolların doğru değerleri için ayar gerekebilir.

  data.throttle = mapJoystickValues( analogRead(A0), 524, 524, 1015, true );
  data.roll = mapJoystickValues( analogRead(A1), 12, 524, 1020, true );      // "true" or "false" for servo direction | "true" veya "false" servo yönünü belirler
  data.pitch = mapJoystickValues( analogRead(A2), 12, 524, 1020, true );     // "true" or "false" for servo direction | "true" veya "false" servo yönünü belirler
  data.yaw = mapJoystickValues( analogRead(A3), 12, 524, 1020, true );       // "true" or "false" for servo direction | "true" veya "false" servo yönünü belirler

  radio.write(&data, sizeof(Signal));
}

This code is responsible for reading the joystick values, mapping them to a range suitable for the application, and transmitting the data wirelessly using the NRF24L01 module. The mapJoystickValues function is used to convert the raw analog readings from the joystick into a format that can be used for controlling servos or motors. The ResetData function initializes the control signals to a neutral position in case of signal loss. The setup function initializes the radio module, and the loop function continuously reads the joystick inputs and sends the data.