我收到错误:
void 值不应被忽略
有人可以帮我解决这个问题吗(我不是专业的 Arduino 编码员)?
当我编译它时,我在第 79 行收到错误:
done = radio.read( received_data, num_received_data );
我不知道如何解决它,甚至不知道这里发生了什么。
#include <Servo.h>
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"
RF24 radio(9,10);
Servo CH1;
Servo CH2;
Servo CH3;
Servo CH4;
Servo CH5;
Servo CH6;
int ch1;
int ch2;
int ch3;
int ch4;
int ch5;
int ch6;
const int CH7 = 4;
const int CH8 = 3;
const int CH9 = 5;
const int CH10 = 2;
const int SIGNAL = 7;
const uint64_t pipe = 0xE8E8F0F0E1LL;
uint8_t received_data[12];
uint8_t num_received_data =sizeof(received_data);
void setup(void)
{
delay(3000);
CH1.attach(15); //right-y(AIL)
CH2.attach(16); //right-x(ELE)
CH3.attach(19); //vol-batt (CH6)
CH4.attach(18); //left-x (CH5)
CH5.attach(17); //left-y (RUD)
CH6.attach(14); //throt
pinMode(CH7, OUTPUT);
pinMode(CH8, OUTPUT);
pinMode(CH9, OUTPUT);
pinMode(CH10, OUTPUT);
pinMode(SIGNAL, OUTPUT);
Serial.begin(57600);
printf_begin();
printf("\n\rRF24/Reciever/\n\r");
radio.begin();
radio.openReadingPipe(1,pipe);
radio.startListening();
radio.printDetails();
}
void loop(void)
{
if ( radio.available() )
{
digitalWrite(SIGNAL, HIGH) ;
}
else {
digitalWrite(SIGNAL, LOW) ;
}
bool done = false;
int ESC_value;
while (!done)
{
done = radio.read( received_data, num_received_data );
//////////////PWM//////////////
ch1=(received_data[1]);
ch1=ch1+3;
CH1.write(ch1);
ch2=(received_data[2]);
ch2=ch2+4;
CH2.write(ch2);
ch3=(received_data[3]);
ch3=ch3+4;
CH3.write(ch3);
ch4=(received_data[4]);
ch4=ch4+4;
CH4.write(ch4);
ch5=(received_data[5]);
ch5=ch5+4;
CH5.write(ch5);
ch6=(received_data[6]);
ch6=ch6+4;
CH6.write(ch6);
//////////////0-1//////////////
if ((received_data[7])>100) {
digitalWrite(CH7, HIGH);
}
else {
digitalWrite(CH7, LOW);
}
//////////////
if ((received_data[8])>100) {
digitalWrite(CH8, HIGH);
}
else {
digitalWrite(CH8, LOW);
}
printf("\n\r");
Serial.print("ROL:");Serial.print(radio.available()); Serial.print("\t");
Serial.print("PITCH:");Serial.print((received_data[2])); Serial.print("\t");
Serial.print("THROT:");Serial.print((received_data[1])); Serial.print("\t");
}
}
我会将其上传到我的 DIY RC 控制器的 atmega328p 上。