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.
D7
connected to NRF24L01 CED8
connected to NRF24L01 CSND11/MOSI
connected to NRF24L01 MOSID12/MISO
connected to NRF24L01 MISOD13/SCK
connected to NRF24L01 SCKA0
connected to KY-023 Joystick Module VRyA1
connected to KY-023 Joystick Module VRxA2
connected to KY-023 Joystick Module VRxA3
connected to KY-023 Joystick Module VRyVIN
connected to the positive side of the power supply netGND
connected to the ground net+
connected to the positive side of the power supply net-
connected to the ground netCE
connected to Arduino Nano D7CSN
connected to Arduino Nano D8MOSI
connected to Arduino Nano D11/MOSIMISO
connected to Arduino Nano D12/MISOSCK
connected to Arduino Nano D13/SCKVCC (3V)
connected to the positive side of the power supply netGND
connected to the ground netGND
connected to the ground net+5V
connected to the positive side of the power supply netVRx
connected to Arduino Nano A1 and A2VRy
connected to Arduino Nano A0 and A3VCC
connected to the ground netGND
connected to the positive side of the power supply net// 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.