I'm trying to make a program to test the functioning of an IR sensor that generates an array of values with the analogRead input from pin A2. While this array generates, with successive elements created with the voltage inputted by the IR sensor, a person moves a flame closer and closer to the IR sensor. In the end, successive element values should get progressively larger (as the flame is moved closer and closer to the sensor while the for loop iterates).
I posted a question earlier about this same code and received a helpful response that allowed me to fix an earlier error. Now I'm receiving a different error (in the subject above). The syntax in the code looks fine now, so I am unsure as to what is wrong. I am experienced in Java but not at all in C++, so maybe there is something that I am missing.
Here is the code:
void setup() {
Serial.begin(9600);
pinMode(A2, INPUT);
}
float IROne[100];
boolean result;
boolean testOne (float IROne []) {
for (int i = 0; i < 100; i++) {
IROne[i] = analogRead(A2);
if (IROne[i] > IROne[i - 1]) {
result = true;
Serial.println(result);
}
}
result = false;
Serial.println(result);
}
Perfect! Thanks; I'm sorry if this was agonizingly-frustrating for you. This is the first program besides an LED blinker and simple analog reader I've had to made and I'm very new to programming.