help with code below

ok it works, but it only spits out the data for those pins in the analog range that are connected to ground or not connected at all. the circuit just consists of 1 inductor, diodes, 1 rectifier but anyway im just confused why the presence of an analog circuit would affect the code working

i have just attached the ino because something odd is happening to firefox

AVGFIND_AVGDEVFIND_STDDEVFIND.ino (2.83 KB)

Cannot see INO file on iPad, just paste the sketch in the post using the code icon.
Show us a schematic and a picture of your circuit.
What is the inductor, may have to use snubbing diode with it.

So that others may see it I'll post your code below. But I find this part particularly strange.
Which arduino has 512 analog inputs?

for(int j=0;j<=512;j++){
     val=analogRead(i)/4;

full original code

#include <EEPROM.h>
int S1 = 0;
int S2 = 0;
int S3 = 0;
int AVGLIST1[8]={
  S1};
int AVGLIST2[8]={
  S1};
int AVGLIST3[8]={
  S1};
int DEVLIST1[8]={
  S2};
float STDDEVLIST[8]={
  S2};





void setup() {
  Serial.begin(9600);

}

void loop() 


{

  for(int k=0;k<2;k++){
    AVGFIND(k);
    AVGDEVFIND(k);
    STDDEVFIND(k);

    if((AVGLIST1[k]!=0)&&(DEVLIST1[k]!=0)){
      Serial.println();
      Serial.print("   PIN:");
      Serial.print(k);
      Serial.print("    ");
      Serial.print("AVERAGE:  ");
      Serial.print(AVGLIST1[k]*(5.0/1023.0));
      Serial.print(" V");
      Serial.print("    ");
      Serial.print("AVG DEVIATION ");
      Serial.print(DEVLIST1[k]*(5.0/1023.0)*(1000));
      Serial.print(" mV");
      Serial.print("    ");
      Serial.print("STD DEVIATION ");
      Serial.print(STDDEVLIST[k]*(5.0/1023.0)*(1));
      Serial.print(" V");
      Serial.print("    ");
    
    }
  }
}

void AVGFIND(int i)
{
  float val;
  float SUM;
  float AVG; 
  { 
    for(int j=0;j<=512;j++){
      val=analogRead(i)/4;
      EEPROM.write(j,val);
      SUM=SUM+4*EEPROM.read(j);

      if(j==512){
        AVG=(SUM)/512;
        if(AVGLIST1[i]!=0){
          AVGLIST1[i]=(AVG+AVGLIST1[i])/2;
          SUM=0;

        }
        else{
          AVGLIST1[i]=AVG;
        }
        SUM=0;
        AVG=0;




      }
    }
  }
}

void AVGDEVFIND(int i)
{
  float SUM = 0;
  float DEVAVG=0;
  {


    for(int j=0;j<=512;j++){
      float val1;
      float val2;



      val1=analogRead(i);
      val2=abs(val1-float(AVGLIST1[i]));
      EEPROM.write(j,val2/4);
      SUM=SUM+4*EEPROM.read(j);

      if(j==512){
        DEVAVG=(SUM)/512;
        if(DEVLIST1[i]!=0){
          DEVLIST1[i]=(DEVAVG+DEVLIST1[i])/2;
          SUM=0;

        }
        else{
          DEVLIST1[i]=DEVAVG;
        }
        SUM=0;
      }
    }
  }
}

void STDDEVFIND(int i)

{
  float val1;
  float val2;
  float val3;
  float SUM1;
  float SUM2;
  float AVG1; 
  float AVG2; 
  {
    for(int j=0;j<=512;j++){
      val1 = analogRead(i);
      val3=pow(val1,2);
      EEPROM.write(j,val1/16);
      SUM1=SUM1+16*EEPROM.read(j);

      if(j==512){
        AVG1=(SUM1)/512;
        if(AVGLIST2[i]!=0){
          AVGLIST2[i]=(AVG1+AVGLIST2[i])/2;
         

        }
        else{
          AVGLIST2[i]=AVG1;
        }
       
       
        for(int j=0;j<=512;j++){
          val2=analogRead(i)/4;
          EEPROM.write(j,val2);
          SUM2=SUM2+4*EEPROM.read(j);

          if(j==512){
            AVG2=(SUM2)/512;
            if(AVGLIST3[i]!=0){
              AVGLIST3[i]=(AVG2+AVGLIST3[i])/2;
              

            }
            else{
              AVGLIST3[i]=AVG2;
            }
           
            

          }
        }
      }
    }
  }
  if((AVGLIST2[i]!=0)&&(AVGLIST3[i]!=0)){
    STDDEVLIST[i]=sqrt(AVGLIST2[i]+pow(AVGLIST3[i],2));AVG2=0; AVG1=0; SUM1=0;SUM2=0;
  }
}

note that there is an 'i' and a 'j' and the i acts as the function arguement that is dictated by the for loop in main that uses 'k'

thanks larry its ok the ive rectified the problem with diodes and a potentiometer the code runs but i have to move the pot up and down a bit.

KenF, the 'j' is meant to be being picked up in the EEPROM write loop thats local i emphasize the word meant to be as well yea i wouldnt be asking for advice otherwise

arduidiot:
KenF, the 'j' is meant to be being picked up in the EEPROM write loop thats local i emphasize the word meant to be as well yea i wouldnt be asking for advice otherwise

Yep that i and j look identical if you don't bother to read the code in something suitable :blush:

no yea i wouldnt doubt that i may have may have mucked up but its just the fact that you get a perfect read out as i intended when i started writing it ( still doesnt mean the values are valid) but when mucking around with analog circuits it fails is what lead me to think this way

basically the ones not showing up are the probes connected to parts of the circuit where the rectifier blocks any readable dV/dt which is of course below 4.89 mV and you'll notice that thoses values show up when you vary the resistence with a potentiometer that gives it a greater than 0 dV/dt, thus the code for finding the average deviation converges to 4.89 mV prior to ceasing to produce a read out for that pin. i have a rough idea what to do.