Global Array Breaking Code


I am having some difficulties working with global arrays in Arduino. The code below summary of my work so far. Everything works nicely until I uncomment the line DI_HR_ARR[DI_COUNT] = DI_HR;, and then it all breaks. By "break the code", I mean that the entire code doesn't run, not even portions of the code that come before that line. It might have something to do with the way I am creating my array, but I checked online and this notation seems to be valid. Maybe there is a better way of coding this?

#define ARRAY_SIZE 200

float DI_HR = 0.0;
int DI_COUNT  = 0;
float DI_HR_ARR[ARRAY_SIZE] = {0.0};

void setup() {
///OTHER CODE: Not shown

void loop() {

///OTHER CODE: Not shown
  if(prev_DI==0 && curr_DI==1){
    DI_HR = calc_HR(); //Function calculates desiered value returns it as a float
    DI_HR_ARR[DI_COUNT] = DI_HR; //Line that breaks the code

///OTHER CODE: Not shown

Maybe it's in the code that's "not shown".

Can't you read!. The rules of this forum [u]require[/u] to post the whole of your code. Those rules apply to YOU.

You are not bright enough to judge which part of your code is wrong if you where you would not be posting the question.


Which Arduino? Some have very small RAMs and a 200 float array is relatively big.

200 floats equals 800 bytes; if you compile for a 328 based board (e.g. Uno), the IDE will start throwing warnings at about 1400 bytes usage; so you are already halfway. Add variables in the functions that you did not show and you might have your culprit.

As said, show your complete code so we don't have to guess.