Hey guys,
I am working on an assignment for class and i'm a bit stuck. What we are trying to do is take voltage inputs from four separate sensors. We then have a table (converted to an array) that correlates each voltage value to a reading (temperature, barometric pressure ect). Anyways, I was curious how one would search for the correct line in the array, and print the correct column (say column 2 for temperature, column 3 for barometric pressure). I am currently getting an error that says invalid types 'float [33][5] float'. I'm not quite sure what this means. Anyways, i'm not looking for someone to do my homework, just looking for a nudge in the right direction to let me know where I am going wrong. Can't seem to find too much help with the array feature on the arduino website.
float WindSpeed = 1;
float WindDirection = 2;
float Temp = 3;
float BarometricPressure = 4;
float Wind_Speed;
float Wind_Direction;
float Temperature;
float Barometric_Pressure;
float raw_WindSpeed;
float raw_WindDirection;
float raw_Temp;
float raw_BarometricPressure;
float Wind_Speed_array[1][5];
float main_array[33][5] =
{
{0.000, 0.000, 0.00, 0.0, 950},
{0.156, 3.125, 11.24, 4.0, 953},
{0.313, 6.250, 22.50, 8.0, 955},
{0.469, 9.375, 33.75, 12.0, 959},
{0.625, 12.500, 45.00, 16.0, 963},
{0.781, 15.625, 56.25, 20.0, 966},
{0.938, 18.750, 67.50, 24.0, 969},
{1.094, 21.875, 78.75, 28.0, 972},
{1.250, 25.000, 90.00, 32.0, 975},
{1.406, 28.125, 101.25, 36.0, 978},
{1.563, 31.250, 112.50, 40.0, 981},
{1.719, 34.375, 123.75, 44.0, 984},
{1.875, 37.500, 135.00, 48.0, 989},
{2.031, 40.625, 146.25, 52.0, 991},
{2.188, 43.750, 157.50, 56.0, 994},
{2.344, 46.875, 168.75, 60.0, 997},
{2.500, 50.000, 180.00, 64.0, 1000},
{2.656, 53.125, 191.25, 68.0, 1003},
{2.813, 56.250, 202.50, 72.0, 1006},
{2.969, 59.375, 213.75, 76.0, 1009},
{3.125, 62.500, 225.00, 80.0, 1013},
{3.281, 65.625, 236.25, 84.0, 1016},
{3.438, 68.750, 247.50, 88.0, 1019},
{3.594, 71.875, 258.75, 92.0, 1022},
{3.750, 75.000, 270.00, 96.0, 1025},
{3.906, 78.125, 281.25, 100.0, 1028},
{4.063, 81.250, 292.50, 104.0, 1031},
{4.219, 84.375, 303.75, 108.0, 1034},
{4.375, 87.500, 315.00, 112.0, 1038},
{4.531, 90.625, 326.25, 116.0, 1041},
{4.688, 93.750, 337.50, 120.0, 1044},
{4.844, 96.875, 348.75, 124.0, 1047},
{5.000, 100.000, 360.00, 128.0, 1050},
};
void setup()
{
Serial.begin(9600);
pinMode(WindSpeed,INPUT);
pinMode(WindDirection,INPUT);
pinMode(Temp,INPUT);
pinMode(BarometricPressure,INPUT);
}
void loop()
{
raw_WindSpeed = analogRead(WindSpeed);
raw_WindDirection = analogRead(WindDirection);
raw_Temp = analogRead(Temp);
raw_BarometricPressure = analogRead(BarometricPressure);
Wind_Speed_array = main_array[raw_WindSpeed];
Serial.print(Wind_Speed_array[0][1]);
}
The last two lines are where I am seeing trouble. I basically want to search the main_array for a value that matches raw_WindSpeed (the voltage from that sensor should match the voltage in the first column of the main array), and set that row of values equal to the Wind_Speed_array. Then I want to print the value in column two of that array.
Anyways, like I said, i'm not looking for someone to do the assignment for me. Just looking for a nudge in the right direction. I'm not quite sure how to search the first column of an array and store the entire row into a separate array.
Moderator edit: CODE TAGS. Please read the stick topic at the top of this section.