Hello,
i'm having a problem i can't quite solve, the program is simple:
i need to capture 64 values from analog pin in an array one time per second, then i want to print those 64 values, flush everything and loop again.
I'm using a non-blocking delay for the interval timer because of the long wait needed between reads.
The problem is that once the i counter reaches "63" which should trigger the for loop to dump the contents the serial output shows... nothing! and jumps from 63 to 94, i don't understand what's going on!.
The IF==63 should trigger and process the entire for loop, then reset the increment counter and keep going
#include <E24.h>
const int shunt = A0; // pata entrada
int currentraw; //valor del ADC
unsigned long previousMillis = 0;
const long interval = 1000;
int lecturas[63]; //almacen de página
byte i;
void setup() {
pinMode (shunt, INPUT);
Serial.begin(115200);
while (!Serial) ;
}
void loop() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
Serial.print("tick ");
Serial.println(i);
i++;
lecturas[i] = analogRead(shunt);
// aca iria el if=64 grabar eeprom
if (i == 63) {
for (byte b = 0; b < 64; b++) {
Serial.println(lecturas[b]);
};
i=0;
}
}
}