我是一个新的编码和过程中建立一个无人机。 我将使用的平台是Arduino UNO,因为我已经下载了IDE,并且从组件的角度对需要发生的事情有了很好的理解。 我已经找到了。 这段代码可以帮助我理解需要编写什么代码,但我希望对代码的逻辑有一些了解。 所以我可能会发送问题来帮助我理解逻辑。
第一个问题与关于声明全局变量的代码有关--现在我理解了全局变量与将在整个代码中使用的变量有关。 我的问题是,有一些全局变量与相同的语法“字节”相关,然后它被分配了一个不同的变量名,我只是想了解一下如何去理解它。
重点问题1/多技能4:
>
在全局变量中声明的项是泛型的,还是会根据您使用的软件类型而变化?
last_channel channel_1_assign receiver_input_channel centre_channel high_channel low_channel之间的区别是什么
下面是用粗体表示的代码
//Declaring Global Variables
byte last_channel_1, last_channel_2, last_channel_3, last_channel_4;
byte lowByte, highByte, type, gyro_address, error, clockspeed_ok;
byte channel_1_assign, channel_2_assign, channel_3_assign, channel_4_assign;
byte roll_axis, pitch_axis, yaw_axis;
byte receiver_check_byte, gyro_check_byte;
volatile int receiver_input_channel_1, receiver_input_channel_2, receiver_input_channel_3,
receiver_input_channel_4;
int center_channel_1, center_channel_2, center_channel_3, center_channel_4;
int high_channel_1, high_channel_2, high_channel_3, high_channel_4;
int low_channel_1, low_channel_2, low_channel_3, low_channel_4;
int address, cal_int;
unsigned long timer, timer_1, timer_2, timer_3, timer_4, current_time;
float gyro_pitch, gyro_roll, gyro_yaw;
float gyro_roll_cal, gyro_pitch_cal, gyro_yaw_cal;
您发布的代码段在同一行声明了多个变量。 为了可读性和组织性,它们被分成多行。
下面是一个简单的例子,它声明了3 int。
int h, w;
int scaling_factor;
// ... (other code here)
int scaled_area = h * w * scaling_factor
我认为您缺乏关于编程的一般信息,这里是一个youtube视频的链接,该视频解释了C++的基础知识。 我建议您观看0:19:55开始的变量部分(以及整个视频的其余部分),这将给您提出更好的问题的单词和基础。
https://www.youtube.com/watch?v=vlnpwxzdw4y