Odd behavior on ADC, please help!

@tim7

I am just trying to help.

In his code, I see to many ----> if () statements.... I am not comfy with that... just pointing this out.

I wonder if the OP connect some voltage into the V ref pin ? Without a analogReference(); in the setup, that may cause some problems. Using A1, well I am not to comfy on that one. I simply use myvalue = analogRead(1); in my opinion. Heh, some may disagree with me, but that is my standard.

Another way of driving common-cathode LEDs is with PNP transitors (emitter to Vcc, collector to load, pull base low to switch transistor on).

That, I agree.

If I was the OP, I will test the code using a pot. I will vary the pot, the leds will light up according to the value at the input of the analog pin. If that work, the amp test will be next. If not, I will fix the code so my leds lights up. To test the amp, I will use a scope <-- if the OP has one. To test the leds, I will do a test code. In the OP case, a simple blink, one led at a time. And also a test code to see the analog pins are working.

When I build my circuit, I always test one section at a time. If any problems, it is easier to isolated the problem.

Here some test code :

Digital pins test

// check all digital pins except pin 1 and 0
// Those a reserved pins for Com link

const byte the_pins[12] = {13,12,11,10,9,8,7,6,5,4,3,2};
int number_of_output = 12;

void setup() 
{                
  for (int i=0;i<number_of_output;i++)
  {
    pinMode(the_pins[i], OUTPUT);
    digitalWrite(the_pins[i], LOW);
  }    
}

void loop() 
{
  for (int i=0;i<number_of_output;i++)
  {
    digitalWrite(the_pins[i], HIGH);
    delay(1000);
    digitalWrite(the_pins[i], LOW);
    delay(500);
  }  
}

Here the analog pins test code :

const byte anapin[6] = {0,1,2,3,4,5};

int my_value[6];

void setup()
{
  analogReference(INTERNAL); // If a voltage at Vref pin, use EXTERNAL
  Serial.begin(9600);
}

void loop()
{
  for (int i=0;i<6;i++)
  {
    my_value[i] = analogRead(anapin[i]);
      
    Serial.print("Analog pin ");
    Serial.print(i, DEC);
    Serial.print(" value : ");
    Serial.println(my_value[i], DEC);
    delay(1000);
  }  
}