6 Kanallı (Opsiyonel 8) Uzaktan Kumanda Nasıl Yapılır? 2000m+ Menzil
Arduino ve 2.4Ghz NRF24L01 Modülleri ile 6 kanallı, uzun menzilli uzaktan kumanda yapımı.
6 Kanallı bu uzaktan kumanda devresi ile RC uçak, RC araba, RC tekne, RC iş makinaları, RC tank gibi model araçları kontrol edebilirsiniz.
İdeal koşullar altında uzaktan kumandanın maksimum menzili 2000 metrenin (1,24 mil+) üzerindedir.
80W Havya: https://s.click.aliexpress.com/e/_DD75tWX
Dijital Multimetre AC DC A830L : https://s.click.aliexpress.com/e/_DmjzgOJ
Dijital Multimetre AC DC ANENG XL830L : https://s.click.aliexpress.com/e/_DEJiyIP
PCB Plaket ölçüleri:
Verici: 114 x 65mm
Alıcı: 60 x 45mm
6-Kanal Verici İçin Arduino Nano Kodu:
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 6 Channel Transmitter | 6 Kanal Verici
// KendinYap Channel
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
const uint64_t pipeOut = 0xABCDABCD71LL; // NOTE: The address in the Transmitter and Receiver code must be the same "0xABCDABCD71LL" | Verici ve Alıcı kodundaki adres aynı olmalıdır
RF24 radio(9, 10); // select CE,CSN pin | CE ve CSN pinlerin seçimi
struct Signal {
byte throttle;
byte pitch;
byte roll;
byte yaw;
byte aux1;
byte aux2;
};
Signal data;
voidResetData()
{
data.throttle = 0;
data.pitch = 127;
data.roll = 127;
data.yaw = 127;
data.aux1 = 0;
data.aux2 = 0;
}
voidsetup()
{
// Configure the NRF24 module | NRF24 modül konfigürasyonu
radio.begin();
radio.openWritingPipe(pipeOut);
radio.setChannel(100);
radio.setAutoAck(false);
radio.setDataRate(RF24_250KBPS); // The lowest data rate value for more stable communication | Daha kararlı iletişim için en düşük veri hızı.
radio.setPALevel(RF24_PA_MAX); // Output power is set for maximum range | Çıkış gücü maksimum menzil için ayarlanıyor.
radio.stopListening(); // Start the radio comunication for Transmitter | Verici için sinyal iletişimini başlatır.
ResetData();
}
// Joystick center and its borders | Joystick merkez ve sınırları
int Border_Map(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 );
}
voidloop()
{
data.roll = Border_Map(analogRead(A3), 0, 512, 1023, true); // CH1 Note: "true" or "false" for signal direction | "true" veya "false" sinyal yönünü belirler
// 6 Channel Transmitter | 6 Kanal Verici
// KendinYap Channel
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
const uint64_t pipeOut = 0xABCDABCD71LL; // NOTE: The address in the Transmitter and Receiver code must be the same "0xABCDABCD71LL" | Verici ve Alıcı kodundaki adres aynı olmalıdır
RF24 radio(9, 10); // select CE,CSN pin | CE ve CSN pinlerin seçimi
struct Signal {
byte throttle;
byte pitch;
byte roll;
byte yaw;
byte aux1;
byte aux2;
};
Signal data;
void ResetData()
{
data.throttle = 0;
data.pitch = 127;
data.roll = 127;
data.yaw = 127;
data.aux1 = 0;
data.aux2 = 0;
}
void setup()
{
// Configure the NRF24 module | NRF24 modül konfigürasyonu
radio.begin();
radio.openWritingPipe(pipeOut);
radio.setChannel(100);
radio.setAutoAck(false);
radio.setDataRate(RF24_250KBPS); // The lowest data rate value for more stable communication | Daha kararlı iletişim için en düşük veri hızı.
radio.setPALevel(RF24_PA_MAX); // Output power is set for maximum range | Çıkış gücü maksimum menzil için ayarlanıyor.
radio.stopListening(); // Start the radio comunication for Transmitter | Verici için sinyal iletişimini başlatır.
ResetData();
}
// Joystick center and its borders | Joystick merkez ve sınırları
int Border_Map(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()
{
data.roll = Border_Map( analogRead(A3), 0, 512, 1023, true ); // CH1 Note: "true" or "false" for signal direction | "true" veya "false" sinyal yönünü belirler
data.pitch = Border_Map( analogRead(A0), 0, 512, 1023, true ); // CH2
data.throttle = Border_Map( analogRead(A2),0, 340, 570, true ); // CH3 Note: For Single side ESC | Tek yönlü ESC için
// data.throttle = Border_Map( analogRead(A2),0, 512, 1023, true ); // CH3 Note: For Bidirectional ESC | Çift yönlü ESC için
data.yaw = Border_Map( analogRead(A1), 0, 512, 1023, false ); // CH4
data.aux1 = digitalRead(0); // CH5
data.aux2 = digitalRead(3); // CH6
radio.write(&data, sizeof(Signal));
}
// 6 Channel Transmitter | 6 Kanal Verici
// KendinYap Channel
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
const uint64_t pipeOut = 0xABCDABCD71LL; // NOTE: The address in the Transmitter and Receiver code must be the same "0xABCDABCD71LL" | Verici ve Alıcı kodundaki adres aynı olmalıdır
RF24 radio(9, 10); // select CE,CSN pin | CE ve CSN pinlerin seçimi
struct Signal {
byte throttle;
byte pitch;
byte roll;
byte yaw;
byte aux1;
byte aux2;
};
Signal data;
void ResetData()
{
data.throttle = 0;
data.pitch = 127;
data.roll = 127;
data.yaw = 127;
data.aux1 = 0;
data.aux2 = 0;
}
void setup()
{
// Configure the NRF24 module | NRF24 modül konfigürasyonu
radio.begin();
radio.openWritingPipe(pipeOut);
radio.setChannel(100);
radio.setAutoAck(false);
radio.setDataRate(RF24_250KBPS); // The lowest data rate value for more stable communication | Daha kararlı iletişim için en düşük veri hızı.
radio.setPALevel(RF24_PA_MAX); // Output power is set for maximum range | Çıkış gücü maksimum menzil için ayarlanıyor.
radio.stopListening(); // Start the radio comunication for Transmitter | Verici için sinyal iletişimini başlatır.
ResetData();
}
// Joystick center and its borders | Joystick merkez ve sınırları
int Border_Map(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()
{
data.roll = Border_Map( analogRead(A3), 0, 512, 1023, true ); // CH1 Note: "true" or "false" for signal direction | "true" veya "false" sinyal yönünü belirler
data.pitch = Border_Map( analogRead(A0), 0, 512, 1023, true ); // CH2
data.throttle = Border_Map( analogRead(A2),0, 340, 570, true ); // CH3 Note: For Single side ESC | Tek yönlü ESC için
// data.throttle = Border_Map( analogRead(A2),0, 512, 1023, true ); // CH3 Note: For Bidirectional ESC | Çift yönlü ESC için
data.yaw = Border_Map( analogRead(A1), 0, 512, 1023, false ); // CH4
data.aux1 = digitalRead(0); // CH5
data.aux2 = digitalRead(3); // CH6
radio.write(&data, sizeof(Signal));
}
6-Kanal Alıcı İçin Arduino Nano Kodu:
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 6 Channel Receiver | 6 Kanal Alıcı
// KendinYap Channel
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Servo.h>
int ch_width_1 = 0;
int ch_width_2 = 0;
int ch_width_3 = 0;
int ch_width_4 = 0;
int ch_width_5 = 0;
int ch_width_6 = 0;
Servo ch1;
Servo ch2;
Servo ch3;
Servo ch4;
Servo ch5;
Servo ch6;
struct Signal {
byte throttle;
byte pitch;
byte roll;
byte yaw;
byte aux1;
byte aux2;
};
Signal data;
const uint64_t pipeIn = 0xABCDABCD71LL;
RF24 radio(9, 10);
voidResetData()
{
data.throttle = 0; // Define the inicial value of each data input. | Veri girişlerinin başlangıç değerleri
data.roll = 127;
data.pitch = 127;
data.yaw = 127;
data.aux1 = 0;
data.aux2 = 0;
}
voidsetup()
{
// Set the pins for each PWM signal | Her bir PWM sinyal için pinler belirleniyor.
ch1.attach(2);
ch2.attach(3);
ch3.attach(4);
ch4.attach(5);
ch5.attach(6);
ch6.attach(7);
ResetData(); // Configure the NRF24 module | NRF24 Modül konfigürasyonu
radio.begin();
radio.openReadingPipe(1,pipeIn);
radio.setChannel(100);
radio.setAutoAck(false);
radio.setDataRate(RF24_250KBPS); // The lowest data rate value for more stable communication | Daha kararlı iletişim için en düşük veri hızı.
radio.setPALevel(RF24_PA_MAX); // Output power is set for maximum | Çıkış gücü maksimum için ayarlanıyor.
radio.startListening(); // Start the radio comunication for receiver | Alıcı için sinyal iletişimini başlatır.
}
unsigned long lastRecvTime = 0;
voidrecvData()
{
while( radio.available()){
radio.read(&data, sizeof(Signal));
lastRecvTime = millis(); // Receive the data | Data alınıyor
}
}
voidloop()
{
recvData();
unsigned long now = millis();
if( now - lastRecvTime >1000){
ResetData(); // Signal lost.. Reset data | Sinyal kayıpsa data resetleniyor
ch1.writeMicroseconds(ch_width_1); // Write the PWM signal | PWM sinyaller çıkışlara gönderiliyor
ch2.writeMicroseconds(ch_width_2);
ch3.writeMicroseconds(ch_width_3);
ch4.writeMicroseconds(ch_width_4);
ch5.writeMicroseconds(ch_width_5);
ch6.writeMicroseconds(ch_width_6);
}
// 6 Channel Receiver | 6 Kanal Alıcı
// KendinYap Channel
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Servo.h>
int ch_width_1 = 0;
int ch_width_2 = 0;
int ch_width_3 = 0;
int ch_width_4 = 0;
int ch_width_5 = 0;
int ch_width_6 = 0;
Servo ch1;
Servo ch2;
Servo ch3;
Servo ch4;
Servo ch5;
Servo ch6;
struct Signal {
byte throttle;
byte pitch;
byte roll;
byte yaw;
byte aux1;
byte aux2;
};
Signal data;
const uint64_t pipeIn = 0xABCDABCD71LL;
RF24 radio(9, 10);
void ResetData()
{
data.throttle = 0; // Define the inicial value of each data input. | Veri girişlerinin başlangıç değerleri
data.roll = 127;
data.pitch = 127;
data.yaw = 127;
data.aux1 = 0;
data.aux2 = 0;
}
void setup()
{
// Set the pins for each PWM signal | Her bir PWM sinyal için pinler belirleniyor.
ch1.attach(2);
ch2.attach(3);
ch3.attach(4);
ch4.attach(5);
ch5.attach(6);
ch6.attach(7);
ResetData(); // Configure the NRF24 module | NRF24 Modül konfigürasyonu
radio.begin();
radio.openReadingPipe(1,pipeIn);
radio.setChannel(100);
radio.setAutoAck(false);
radio.setDataRate(RF24_250KBPS); // The lowest data rate value for more stable communication | Daha kararlı iletişim için en düşük veri hızı.
radio.setPALevel(RF24_PA_MAX); // Output power is set for maximum | Çıkış gücü maksimum için ayarlanıyor.
radio.startListening(); // Start the radio comunication for receiver | Alıcı için sinyal iletişimini başlatır.
}
unsigned long lastRecvTime = 0;
void recvData()
{
while ( radio.available() ) {
radio.read(&data, sizeof(Signal));
lastRecvTime = millis(); // Receive the data | Data alınıyor
}
}
void loop()
{
recvData();
unsigned long now = millis();
if ( now - lastRecvTime > 1000 ) {
ResetData(); // Signal lost.. Reset data | Sinyal kayıpsa data resetleniyor
}
ch_width_1 = map(data.roll, 0, 255, 1000, 2000);
ch_width_2 = map(data.pitch, 0, 255, 1000, 2000);
ch_width_3 = map(data.throttle, 0, 255, 1000, 2000);
ch_width_4 = map(data.yaw, 0, 255, 1000, 2000);
ch_width_5 = map(data.aux1, 0, 1, 1000, 2000);
ch_width_6 = map(data.aux2, 0, 1, 1000, 2000);
ch1.writeMicroseconds(ch_width_1); // Write the PWM signal | PWM sinyaller çıkışlara gönderiliyor
ch2.writeMicroseconds(ch_width_2);
ch3.writeMicroseconds(ch_width_3);
ch4.writeMicroseconds(ch_width_4);
ch5.writeMicroseconds(ch_width_5);
ch6.writeMicroseconds(ch_width_6);
}
// 6 Channel Receiver | 6 Kanal Alıcı
// KendinYap Channel
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Servo.h>
int ch_width_1 = 0;
int ch_width_2 = 0;
int ch_width_3 = 0;
int ch_width_4 = 0;
int ch_width_5 = 0;
int ch_width_6 = 0;
Servo ch1;
Servo ch2;
Servo ch3;
Servo ch4;
Servo ch5;
Servo ch6;
struct Signal {
byte throttle;
byte pitch;
byte roll;
byte yaw;
byte aux1;
byte aux2;
};
Signal data;
const uint64_t pipeIn = 0xABCDABCD71LL;
RF24 radio(9, 10);
void ResetData()
{
data.throttle = 0; // Define the inicial value of each data input. | Veri girişlerinin başlangıç değerleri
data.roll = 127;
data.pitch = 127;
data.yaw = 127;
data.aux1 = 0;
data.aux2 = 0;
}
void setup()
{
// Set the pins for each PWM signal | Her bir PWM sinyal için pinler belirleniyor.
ch1.attach(2);
ch2.attach(3);
ch3.attach(4);
ch4.attach(5);
ch5.attach(6);
ch6.attach(7);
ResetData(); // Configure the NRF24 module | NRF24 Modül konfigürasyonu
radio.begin();
radio.openReadingPipe(1,pipeIn);
radio.setChannel(100);
radio.setAutoAck(false);
radio.setDataRate(RF24_250KBPS); // The lowest data rate value for more stable communication | Daha kararlı iletişim için en düşük veri hızı.
radio.setPALevel(RF24_PA_MAX); // Output power is set for maximum | Çıkış gücü maksimum için ayarlanıyor.
radio.startListening(); // Start the radio comunication for receiver | Alıcı için sinyal iletişimini başlatır.
}
unsigned long lastRecvTime = 0;
void recvData()
{
while ( radio.available() ) {
radio.read(&data, sizeof(Signal));
lastRecvTime = millis(); // Receive the data | Data alınıyor
}
}
void loop()
{
recvData();
unsigned long now = millis();
if ( now - lastRecvTime > 1000 ) {
ResetData(); // Signal lost.. Reset data | Sinyal kayıpsa data resetleniyor
}
ch_width_1 = map(data.roll, 0, 255, 1000, 2000);
ch_width_2 = map(data.pitch, 0, 255, 1000, 2000);
ch_width_3 = map(data.throttle, 0, 255, 1000, 2000);
ch_width_4 = map(data.yaw, 0, 255, 1000, 2000);
ch_width_5 = map(data.aux1, 0, 1, 1000, 2000);
ch_width_6 = map(data.aux2, 0, 1, 1000, 2000);
ch1.writeMicroseconds(ch_width_1); // Write the PWM signal | PWM sinyaller çıkışlara gönderiliyor
ch2.writeMicroseconds(ch_width_2);
ch3.writeMicroseconds(ch_width_3);
ch4.writeMicroseconds(ch_width_4);
ch5.writeMicroseconds(ch_width_5);
ch6.writeMicroseconds(ch_width_6);
}
PCB Plaket ölçüleri:
Verici: 122 x 75mm
Alıcı: 60 x 45mm
8 Kanal Verici için Arduino Nano Kodu:
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 8 Channel Transmitter | 8 Kanal Verici
// KendinYap Channel
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
const uint64_t pipeOut = 0xABCDABCD71LL; // NOTE: The address in the Transmitter and Receiver code must be the same "0xABCDABCD71LL" | Verici ve Alıcı kodundaki adres aynı olmalıdır
RF24 radio(9, 10); // select CE,CSN pins | CE ve CSN pinlerin seçimi
struct Signal {
byte throttle;
byte pitch;
byte roll;
byte yaw;
byte aux1;
byte aux2;
byte aux3;
byte aux4;
};
Signal data;
voidResetData()
{
data.throttle = 0;
data.pitch = 127;
data.roll = 127;
data.yaw = 127;
data.aux1 = 0;
data.aux2 = 0;
data.aux3 = 0;
data.aux4 = 0;
}
voidsetup()
{
// Configure the NRF24 module | NRF24 modül konfigürasyonu
radio.begin();
radio.openWritingPipe(pipeOut);
radio.setChannel(100);
radio.setAutoAck(false);
radio.setDataRate(RF24_250KBPS); // The lowest data rate value for more stable communication | Daha kararlı iletişim için en düşük veri hızı.
radio.setPALevel(RF24_PA_MAX); // Output power is set for maximum range | Çıkış gücü maksimum menzil için ayarlanıyor.
radio.stopListening(); // Start the radio comunication for Transmitter | Verici için sinyal iletişimini başlatır.
ResetData();
}
// Joystick center and its borders | Joystick merkez ve sınırları
int Border_Map(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 );
}
voidloop()
{
data.roll = Border_Map(analogRead(A7), 0, 512, 1023, true); // CH1 Note: "true" or "false" for signal direction | "true" veya "false" sinyal yönünü belirler
// 8 Channel Transmitter | 8 Kanal Verici
// KendinYap Channel
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
const uint64_t pipeOut = 0xABCDABCD71LL; // NOTE: The address in the Transmitter and Receiver code must be the same "0xABCDABCD71LL" | Verici ve Alıcı kodundaki adres aynı olmalıdır
RF24 radio(9, 10); // select CE,CSN pins | CE ve CSN pinlerin seçimi
struct Signal {
byte throttle;
byte pitch;
byte roll;
byte yaw;
byte aux1;
byte aux2;
byte aux3;
byte aux4;
};
Signal data;
void ResetData()
{
data.throttle = 0;
data.pitch = 127;
data.roll = 127;
data.yaw = 127;
data.aux1 = 0;
data.aux2 = 0;
data.aux3 = 0;
data.aux4 = 0;
}
void setup()
{
// Configure the NRF24 module | NRF24 modül konfigürasyonu
radio.begin();
radio.openWritingPipe(pipeOut);
radio.setChannel(100);
radio.setAutoAck(false);
radio.setDataRate(RF24_250KBPS); // The lowest data rate value for more stable communication | Daha kararlı iletişim için en düşük veri hızı.
radio.setPALevel(RF24_PA_MAX); // Output power is set for maximum range | Çıkış gücü maksimum menzil için ayarlanıyor.
radio.stopListening(); // Start the radio comunication for Transmitter | Verici için sinyal iletişimini başlatır.
ResetData();
}
// Joystick center and its borders | Joystick merkez ve sınırları
int Border_Map(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()
{
data.roll = Border_Map( analogRead(A7), 0, 512, 1023, true ); // CH1 Note: "true" or "false" for signal direction | "true" veya "false" sinyal yönünü belirler
data.pitch = Border_Map( analogRead(A6), 0, 512, 1023, true ); // CH2
data.throttle = Border_Map( analogRead(A3),0, 570, 800, true ); // CH3 Note: For Single side ESC | Tek yönlü ESC için
// data.throttle = Border_Map( analogRead(A3),0, 512, 1023, true ); // CH3 Note: For Bidirectional ESC | Çift yönlü ESC için
data.yaw = Border_Map( analogRead(A4), 0, 512, 1023, false ); // CH4
data.aux1 = digitalRead(0); // CH5
data.aux2 = digitalRead(3); // CH6
data.aux3 = Border_Map( analogRead(A0),0, 512, 1023, true ); // CH7
data.aux4 = Border_Map( analogRead(A1),0, 512, 1023, true ); // CH8
radio.write(&data, sizeof(Signal));
}
// 8 Channel Transmitter | 8 Kanal Verici
// KendinYap Channel
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
const uint64_t pipeOut = 0xABCDABCD71LL; // NOTE: The address in the Transmitter and Receiver code must be the same "0xABCDABCD71LL" | Verici ve Alıcı kodundaki adres aynı olmalıdır
RF24 radio(9, 10); // select CE,CSN pins | CE ve CSN pinlerin seçimi
struct Signal {
byte throttle;
byte pitch;
byte roll;
byte yaw;
byte aux1;
byte aux2;
byte aux3;
byte aux4;
};
Signal data;
void ResetData()
{
data.throttle = 0;
data.pitch = 127;
data.roll = 127;
data.yaw = 127;
data.aux1 = 0;
data.aux2 = 0;
data.aux3 = 0;
data.aux4 = 0;
}
void setup()
{
// Configure the NRF24 module | NRF24 modül konfigürasyonu
radio.begin();
radio.openWritingPipe(pipeOut);
radio.setChannel(100);
radio.setAutoAck(false);
radio.setDataRate(RF24_250KBPS); // The lowest data rate value for more stable communication | Daha kararlı iletişim için en düşük veri hızı.
radio.setPALevel(RF24_PA_MAX); // Output power is set for maximum range | Çıkış gücü maksimum menzil için ayarlanıyor.
radio.stopListening(); // Start the radio comunication for Transmitter | Verici için sinyal iletişimini başlatır.
ResetData();
}
// Joystick center and its borders | Joystick merkez ve sınırları
int Border_Map(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()
{
data.roll = Border_Map( analogRead(A7), 0, 512, 1023, true ); // CH1 Note: "true" or "false" for signal direction | "true" veya "false" sinyal yönünü belirler
data.pitch = Border_Map( analogRead(A6), 0, 512, 1023, true ); // CH2
data.throttle = Border_Map( analogRead(A3),0, 570, 800, true ); // CH3 Note: For Single side ESC | Tek yönlü ESC için
// data.throttle = Border_Map( analogRead(A3),0, 512, 1023, true ); // CH3 Note: For Bidirectional ESC | Çift yönlü ESC için
data.yaw = Border_Map( analogRead(A4), 0, 512, 1023, false ); // CH4
data.aux1 = digitalRead(0); // CH5
data.aux2 = digitalRead(3); // CH6
data.aux3 = Border_Map( analogRead(A0),0, 512, 1023, true ); // CH7
data.aux4 = Border_Map( analogRead(A1),0, 512, 1023, true ); // CH8
radio.write(&data, sizeof(Signal));
}
8 Kanal Alıcı İçin Arduino Nano Kodu:
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 8-Channel Receiver | 8 Kanal Alıcı
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Servo.h>
int ch_width_1 = 0;
int ch_width_2 = 0;
int ch_width_3 = 0;
int ch_width_4 = 0;
int ch_width_5 = 0;
int ch_width_6 = 0;
int ch_width_7 = 0;
int ch_width_8 = 0;
Servo ch1;
Servo ch2;
Servo ch3;
Servo ch4;
Servo ch5;
Servo ch6;
Servo ch7;
Servo ch8;
struct Signal {
byte throttle;
byte pitch;
byte roll;
byte yaw;
byte aux1;
byte aux2;
byte aux3;
byte aux4;
};
Signal data;
const uint64_t pipeIn = 0xABCDABCD71LL;
RF24 radio(9, 10);
voidResetData()
{
data.throttle = 0; // Define the inicial value of each data input. | Veri girişlerinin başlangıç değerleri
data.roll = 127;
data.pitch = 127;
data.yaw = 127;
data.aux1 = 0;
data.aux2 = 0;
data.aux3 = 0;
data.aux4 = 0;
}
voidsetup()
{
// Set the pins for each PWM signal | Her bir PWM sinyal için pinler belirleniyor.
ch1.attach(2);
ch2.attach(3);
ch3.attach(4);
ch4.attach(5);
ch5.attach(6);
ch6.attach(7);
ch7.attach(8);
ch8.attach(0);
ResetData(); // Configure the NRF24 module | NRF24 Modül konfigürasyonu
radio.begin();
radio.openReadingPipe(1,pipeIn);
radio.setChannel(100);
radio.setAutoAck(false);
radio.setDataRate(RF24_250KBPS); // The lowest data rate value for more stable communication | Daha kararlı iletişim için en düşük veri hızı.
radio.setPALevel(RF24_PA_MAX); // Output power is set for maximum | Çıkış gücü maksimum için ayarlanıyor.
radio.startListening(); // Start the radio comunication for receiver | Alıcı için sinyal iletişimini başlatır.
}
unsigned long lastRecvTime = 0;
voidrecvData()
{
while( radio.available()){
radio.read(&data, sizeof(Signal));
lastRecvTime = millis(); // Receive the data | Data alınıyor
}
}
voidloop()
{
recvData();
unsigned long now = millis();
if( now - lastRecvTime >1000){
ResetData(); // Signal lost.. Reset data | Sinyal kayıpsa data resetleniyor
7. ve 8. kanal potansiyometre ile kontrol ediliyor. Potansları PCB üzerine yapıştırıcı ile dik bir şekilde yerleştirmek gerekiyor. Pot pinlerini L şeklinde bükebilirsiniz. Ama pinler kısa olduğu için kablo ile uzatmak gerekecektir.
GENEL BİLGİLER:
Kodları Arduino’ya yüklemeden önce gerekli kütüphane dosyalarını bilgisayarınıza indirmeniz gerekmektedir.
Kütüphane dosyası yoksa kurulum gerçekleşmeyecek ve hata oluşacaktır.
İndirmek için linkler …..:
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional
Her zaman aktif
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.