I'm trying to incorporate structs into my code, but I'm getting a type error.
Basically, I'm trying to initialize a struct and all of its member variables outside of the setup() and loop() functions. Like this:
struct controlSurfaces
{
byte command_index;
byte rate_pin;
uint16_t _offset;
uint16_t high_rates_surface_max;
uint16_t high_rates_surface_min;
uint16_t low_rates_surface_max;
uint16_t low_rates_surface_min;
uint16_t ADC_max;
uint16_t ADC_min;
}ailerons;
/////////////////////////////////////////////////////////////////////////////////////////
//setup aileron struct
ailerons.command_index = 0;
ailerons.rate_pin = 0;
ailerons.high_rates_surface_max = 0;
ailerons.high_rates_surface_min = 0;
ailerons.low_rates_surface_max = 0;
ailerons.low_rates_surface_min = 0;
ailerons.ADC_max = 0;
ailerons.ADC_min = 0;
/////////////////////////////////////////////////////////////////////////////////////////
void setup()
{
//do nothing
}
void loop()
{
//do nothing
}
But it gives me this error: 'ailerons' does not name a type
I did some research and I found that in C++ you can do the following:
struct Employee
{
short id;
int age;
double wage;
};
Employee joe;
joe.id = 1;
joe.age = 32;
joe.wage = 60000.0;
Which, as far as I can tell, is exactly what I did in my sketch. What is going wrong?