Stuck with program flow and freezing programm

int reading[15] = {0}; //declaring a local var to hold
//the readings
for(int i=0; i<15; i++){ //take 10 readings
reading += analogRead(lightSensor);

  • }*
  • //average the readings*
  • sensorValue = (reading[0] + reading[1] + reading[2] + reading[3] +*
  • reading[4] + reading[5] + reading[6] + reading[7] +*
  • reading[8] + reading[9] + reading[10] + reading[11] +*
  • reading[12] + reading[13] + reading[14]) / 15;*
    There's a waste of 30 bytes. Set sensorValue to 0, then increment it by the reading divided by 10 in the loop. Then, divide by 15. There is no reason to store the data in an array.[/quote]
    I changed this part to
    ```
  • sensorValue = 0;
        int reading = 0;                                  //the readings
        for(int i=0; i<15; i++){                      //take 15readings
          int value = analogRead(lightSensor);
          reading = reading + value;
        }
        //average the readings
        sensorValue = reading / 15;
      //Serial.print("Sensor value: ");*
    ```
    It looks like everything is stable again. It's running since about 10 minutes without visible problems.
    Thank you very much for the help.
    However, if you have a hint how to get the menu into that without running into memory problems again, I would be very happy to hear about.
    Again, thanks for your help