100元用Arduino做一个RC遥控飞机-arduino飞机代码

视频时间

1.遥控器与飞机的电子设计与编程:0:45

2.飞机主体的搭建制作:4:50

制作需要准备

2 x Arduino Nano

1 x NRF24L01 + PA 无线收发模块

1 x NRF24L01 无线收发模块

2 x Arduino joystick

2 x 100uF 电容 (16V 以上)

1 x 13 * 6 cm PCB 电木板

1 x 5 * 3.5 cm PCB 电木板

3 x SG90 舵机

1 x 20A ESC 电子调速器

2 x 7.4V 450Mah 2S 锂电池

1 x DC 180 Motor 39000 RPM 电机+螺旋桨

5mmKT板/泡沫板/雪弗板

舵机夹头、金属调节器、1mm铁丝

视频内容

今天就给大家分享一个油管上KendinYap,K大的Arduino的低成本无线遥控飞机,总共材料费用是在100元左右。

100元用Arduino做一个RC遥控飞机-arduino飞机代码

除了遥控飞机,今天介绍的制作方式也可以应用在制作无人机、遥控车、遥控船这类东西,解说分成遥控器跟飞机两部分。

100元用Arduino做一个RC遥控飞机-arduino飞机代码

遥控器能够控制3个舵机跟1个直流电机,这里的控制主板选用的是Arduino Nano,应该是为了降低成本,因为遥控器本身需要连接的电子元件并不多,控制飞机用了两个Joystick摇杆、一个NRF24L01PA的大功率无线收发模块、一个100微法的电容、1个7.4V的锂电池。

100元用Arduino做一个RC遥控飞机-arduino飞机代码

100元用Arduino做一个RC遥控飞机-arduino飞机代码

飞机上使用的一样是Arduino Nano,3个SG90舵机、1个39000转的直流电机、100微法的电容、一个30A双向有刷电调,1个NRF24L01无线收发模块,一个7.4V锂电池。

100元用Arduino做一个RC遥控飞机-arduino飞机代码

100元用Arduino做一个RC遥控飞机-arduino飞机代码

机身的尺寸是45.3厘米,属于偏迷你大小的飞机,这里制作采用的是泡沫板/PVC板/雪弗板/KT板,使用热熔胶枪粘合。

100元用Arduino做一个RC遥控飞机-arduino飞机代码

连杆机构使用了舵机夹头跟金属调节器。

100元用Arduino做一个RC遥控飞机-arduino飞机代码

100元用Arduino做一个RC遥控飞机-arduino飞机代码

遥控器电路图

100元用Arduino做一个RC遥控飞机-arduino飞机代码

遥控器Arduino代码

// 4 Channel Transmitter | 4 Kanal Verici #include #include #include 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ıyorResetData();} // 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);elseval = 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ü belirlerdata.pitch = mapJoystickValues( analogRead(A2), 12, 524, 1020, true ); // “true” or “false” for servo direction | “true” veya “false” servo yönünü belirlerdata.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));}‍

飞机上的电路主板也是用Arduino Nano,3个SG90舵机、1个39000转的直流电机、100微法的电容、一个30A双向有刷电调,1个NRF24L01无线收发模块,一个7.4V锂电池。

飞机控制电路图

100元用Arduino做一个RC遥控飞机-arduino飞机代码

飞机控制Arduino代码

// 4 Channel Receiver | 4 Kanal Alıcı// PWM output on pins D2, D3, D4, D5 (Çıkış pinleri) #include #include #include #include int ch_width_1 = 0;int ch_width_2 = 0;int ch_width_3 = 0;int ch_width_4 = 0; Servo ch1;Servo ch2;Servo ch3;Servo ch4; struct Signal {byte throttle;byte pitch;byte roll;byte yaw;}; Signal data; const uint64_t pipeIn = 0xE9E8F0F0E1LL;RF24 radio(7, 8); void ResetData(){// Define the inicial value of each data input. | Veri girişlerinin başlangıç değerleri// The middle position for Potenciometers. (254/2=127) | Potansiyometreler için orta konumdata.throttle = 127; // Motor Stop | Motor Kapalıdata.pitch = 127; // Center | Merkezdata.roll = 127; // Center | Merkezdata.yaw = 127; // Center | Merkez} 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); //Configure the NRF24 module ResetData(); radio.begin(); radio.openReadingPipe(1,pipeIn); radio.startListening(); //start the radio comunication for receiver | Alıcı olarak sinyal iletişimi başlatılıyor} 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.throttle, 0, 255, 1000, 2000); // pin D2 (PWM signal)ch_width_2 = map(data.pitch, 0, 255, 1000, 2000); // pin D3 (PWM signal)ch_width_3 = map(data.roll, 0, 255, 1000, 2000); // pin D4 (PWM signal)ch_width_4 = map(data.yaw, 0, 255, 1000, 2000); // pin D5 (PWM signal) // Write the PWM signal | PWM sinyaller çıkışlara gönderiliyorch1.writeMicroseconds(ch_width_1);ch2.writeMicroseconds(ch_width_2);ch3.writeMicroseconds(ch_width_3);ch4.writeMicroseconds(ch_width_4);}

审核编辑黄宇

免责声明:文章内容来自互联网,本站不对其真实性负责,也不承担任何法律责任,如有侵权等情况,请与本站联系删除。
转载请注明出处:100元用Arduino做一个RC遥控飞机-arduino飞机代码 https://www.yhzz.com.cn/a/4643.html

上一篇 2023-04-11 04:17:34
下一篇 2023-04-11 04:22:54

相关推荐

联系云恒

在线留言: 我要留言
客服热线:400-600-0310
工作时间:周一至周六,08:30-17:30,节假日休息。