Too few arguments to function

Hi there,

I have a problem with the following error code:

error: too few arguments to function 'int analogRead(uint8_t)'

This occurs towards the end of the script. I have googled it and saw a post similar where AWOL commented that this is a very easy error code to understand: I am not giving analogRead enough arguments to perform its function. But I don't understand why when I have it in the same format in another code and it works. Suspect is to do with combining it with the if statements in my LOOP function? Not sure where to put it in terms of the curly brackets.

Here is the code:

//BOARD LAYOUT 
#define A 8
#define B 9
#define C 10
#define D 11
#define E 12
#define sensor
int val=0;
#define DELAY 500
int c[5][4][2] = {
{ {A, B}, {A, C}, {A, D}, {A, E} },
{ {B, A}, {B, C}, {B, D}, {B, E} },
{ {C, A}, {C, B}, {C, D}, {C, E} },
{ {D, A}, {D, B}, {D, C}, {D, E} },
{ {E, A}, {E, B}, {E, C}, {E, D} }
};
int frames[][5] = 
{
// Twenty LED s on:
/*{ 0b1111,
0b1111,
0b1111,
0b1111,
0b1111
}*/
};

//SETUP
void setup()
{
pinMode( A, INPUT );
pinMode( B, INPUT );
pinMode( C, INPUT );
pinMode( D, INPUT );
pinMode( E, INPUT );
Serial.begin(9600);
}
void display( int frame[5], int duration )
{
  int times = 0;
  int x = 0;
  int y = 0;
  while( times < duration )
      {
        for( y = 0; y < 5; y++ )
      {
        for( x = 0; x < 4; x++ )
      {
        setup();
        if( frame[y] & (0b1111>> x) )
          {
            light( c[y][x] );
            delayMicroseconds(DELAY);
            times++;
          }
      }
    }
    }
    }
void light( int pins[2] ){
pinMode( pins[0], OUTPUT );
digitalWrite( pins[0], HIGH );
pinMode( pins[1], OUTPUT );
digitalWrite( pins[1], LOW );
}
void test( int pins[2] ){
setup();
light(pins);
delay(500);
}
void test_loop(){
for( int i=0; i<5; i++ ){
for( int j=0; j<4; j++ ){
test(c[i][j]);
}
}
}

//LOOP
void loop()
{
  {int i;
  for( i = 1; i < 20; i++ )
  display( frames[23], 4000);
  }
  val=analogRead(sensor);
  Serial.println(val);
  
  //delay(10);

}

#define sensor

is an empty define

try

#define sensor A0

and please try to get a better layout of { } as the code is hard to read ...

Hi robtillaart,

Perfect, can't believe I missed that...

Thanks so much!

Yeah, sorry about the state of my code, I like to have all of my curly brackets exploded so I can see exactly what is inside them, but I definitely should have ctrl+t-ed my code before pasting! Sorry, :slight_smile:

Why does test() (a stupid name, by the way) call setup()?