Store global variables in computer memory

I was making a program so that i can use arduino to calculate actual battery capacity (mah) and i defined float arrays with 600 elements so i can store voltage over time. Now i know that this task can be done with quite simpler codes but here is one that i wrote:

const int pushButton = 8;
const float R = 22;

float mahcalculator (float arr[600] , int s);

void setup() {

  pinMode (pushButton, INPUT);
  Serial.println("Press the button on pin 8 to start!");
  bool pushButtonState;
  do {
    pushButtonState = digitalRead(pushButton);
  } while (pushButtonState == LOW);
  Serial.println("Program Started!");
  Serial.println("Measuring initial voltages on pins A0-A5");


  float initial_A0 = ((analogRead(A0))/1023)*(5); 
  float initial_A1 = ((analogRead(A1))/1023)*(5); 
  float initial_A2 = ((analogRead(A2))/1023)*(5); 
  float initial_A3 = ((analogRead(A3))/1023)*(5); 
  float initial_A4 = ((analogRead(A4))/1023)*(5); 
  float initial_A5 = ((analogRead(A5))/1023)*(5); 
  Serial.print("Voltage on pin A0= ");    Serial.println(initial_A0);
  Serial.print("Voltage on pin A1= ");    Serial.println(initial_A1);
  Serial.print("Voltage on pin A2= ");    Serial.println(initial_A2);
  Serial.print("Voltage on pin A3= ");    Serial.println(initial_A3);
  Serial.print("Voltage on pin A4= ");    Serial.println(initial_A4);
  Serial.print("Voltage on pin A5= ");    Serial.println(initial_A5);


float amps_over_timeA0[600];
float amps_over_timeA1[600];
float amps_over_timeA2[600];
float amps_over_timeA3[600];
float amps_over_timeA4[600];
float amps_over_timeA5[600];
int T_time = 0;

void loop() {

  int s0,s1,s2,s3,s4,s5;
  amps_over_timeA0[T_time] = ((analogRead(A0))/1023)*(5); 
  amps_over_timeA1[T_time] = ((analogRead(A1))/1023)*(5); 
  amps_over_timeA2[T_time] = ((analogRead(A2))/1023)*(5); 
  amps_over_timeA3[T_time] = ((analogRead(A3))/1023)*(5); 
  amps_over_timeA4[T_time] = ((analogRead(A4))/1023)*(5); 
  amps_over_timeA5[T_time] = ((analogRead(A5))/1023)*(5); 

  if (amps_over_timeA0[T_time] < 3.6)
    s0 = T_time;

  if (amps_over_timeA1[T_time] < 3.6)
    s1 = T_time;

  if (amps_over_timeA2[T_time] < 3.6)
    s2 = T_time;

  if (amps_over_timeA3[T_time] < 3.6)
    s3 = T_time;

  if (amps_over_timeA4[T_time] < 3.6)
    s4 = T_time;

  if (amps_over_timeA5[T_time] < 3.6)
    s5 = T_time;

  if ( == 's') {
    Serial.print("Voltage on pin A0= ");    Serial.println(amps_over_timeA0[T_time]);
    Serial.print("Voltage on pin A1= ");    Serial.println(amps_over_timeA1[T_time]);
    Serial.print("Voltage on pin A2= ");    Serial.println(amps_over_timeA2[T_time]);
    Serial.print("Voltage on pin A3= ");    Serial.println(amps_over_timeA3[T_time]);
    Serial.print("Voltage on pin A4= ");    Serial.println(amps_over_timeA4[T_time]);
    Serial.print("Voltage on pin A5= ");    Serial.println(amps_over_timeA5[T_time]);

  if ( == 'x') {
    Serial.print("mah of battery at A0 = ");    Serial.println(mahcalculator(amps_over_timeA0, s0));
    Serial.print("mah of battery at A1 = ");    Serial.println(mahcalculator(amps_over_timeA1, s1));
    Serial.print("mah of battery at A2 = ");    Serial.println(mahcalculator(amps_over_timeA2, s2));
    Serial.print("mah of battery at A3 = ");    Serial.println(mahcalculator(amps_over_timeA3, s3));
    Serial.print("mah of battery at A4 = ");    Serial.println(mahcalculator(amps_over_timeA4, s4));
    Serial.print("mah of battery at A5 = ");    Serial.println(mahcalculator(amps_over_timeA5, s5));



float mahcalculator(float arr[600] , int s) {

  float avgamp = 0;
  for (int i=0 ; i<= s ; i++) {
    avgamp += arr[i]/R;

  return avgamp*(s/60);

Now i know that this code is a memory eating junk and guess what it got 708% of dynamic memory.

My real question is that can i define a variable or array in general in computer’s memory so that this code may work. Or maybe a computer program to get data from arduino and do my calculations. IF possible then how?

after some calculations you are using floats to store your readings
why not store the original analouge readings as ints and do the float calculations when you use the values
this should reduce the SRAM requirements by half

you could

  1. move to a more powerful processor such as the Arduino Due or a Raspberry Pie
  2. store data to an SD - you could then process more data

do you need to store the readings?
could you maintain a sum of values and divide by the number of values read?

Yeah, thanks horace.

I might just go for that. I have a lot of other solutions too actually. But I was just curious that when arduino is connected to computer so there must be a way through serial comm. that i store the data in PC rather than SRAM in arduino. I was wondering if arduino IDE supports this or not.

you are already writing information to the serial port regarding the acquired data.
you could implement a program on the PC written in C++, C#, VB, Java, Python, Matlab, etc to read the serial data do the calculations and present the results in a GUI, graph, etc.
If you use Windows Visual studio express is free

if you are reasonably proficient in C/C++ i would suggest Visual C# - it is very easy to build GUIs and has a SerialPort component in the toolbox to communicate with the serial COM port

also have a look at

float initial_A0 = ((analogRead(A0))/1023)*(5);

as all the factors in this equation are ints the result will be int and probably 0.

doing the math this way let the compiler calculate the constant compile time
and the result will be more accurate.

float initial_A0 = analogRead(A0) * (5.0/1023.0);