Arduino Forum

Using Arduino => Programming Questions => Topic started by: ChallengingRiptide on Aug 02, 2020, 09:33 am

Title: I keep getting this error message and I don't know what causes it
Post by: ChallengingRiptide on Aug 02, 2020, 09:33 am
This is the error code I get:
148:33: error: too many arguments to function 'int digitalRead(uint8_t)' and
90:32: error: too many arguments to function 'int digitalRead(uint8_t)'
I have no idea what causes it, and I've tried everything that came to my mind(nothing came to my mind
The only thing I connected is a 4 by 4 keypad

Code: [Select]
int input1, input2;//First and second number
int output;//The output
int first_number, second_number;//Used to know if the first or second number has been set
int a1;
int operation;//Used to kow which operation (addition, subtraction ect.) was selected
void setup() {
  pinMode(2, INPUT);
  pinMode(3, INPUT);
  pinMode(4, INPUT);
  pinMode(5, INPUT);
  pinMode(6, INPUT);
  pinMode(7, INPUT);
  pinMode(8, INPUT);
  pinMode(9, INPUT);
  Serial.begin(9600);//Initialize serial communications
}
void loop() {
  while(digitalRead(2) == LOW && digitalRead(3) == LOW && digitalRead(4) == LOW && digitalRead(5) == LOW && digitalRead(6) == LOW && digitalRead(7) == LOW && digitalRead(8) == LOW && digitalRead(9) == LOW){}
  if(digitalRead(9) == HIGH);
  a1=1;
  if(digitalRead(5)==HIGH){
    if(digitalRead(7) == LOW);
    a1=1;
  }
  if (a1=1) {//Seeing if a number was pressed
    if (operation == 0) { //To check if it's for the first number
      if(digitalRead(2) == HIGH){
        for(byte i=6; i<9; i++){
          if(digitalRead(i) == HIGH){
            input1*=10;
            input1+=(i-5);
          }
        }
      }
      if(digitalRead(3) == HIGH){
        for(byte i=6; i<9; i++){
          if(digitalRead(i) == HIGH){
            input1*=10;
            input1+=(i-2);
          }
        }
      }
      if(digitalRead(4) == HIGH){
        for(byte i=6; i<9; i++){
          if(digitalRead(i) == HIGH){
            input1*=10;
            input1+=(i+1);
          }
        }
      }
      if(digitalRead(5) == HIGH);
      input1*=10;
    }else{
      if(digitalRead(2) == HIGH){
        for(byte i=6; i<9; i++){
          if(digitalRead(i) == HIGH){
            input2*=10;
            input2+=(i-5);
          }
        }
      }
      if(digitalRead(3) == HIGH){
        for(byte i=6; i<9; i++){
          if(digitalRead(i) == HIGH){
            input2*=10;
            input2+=(i-2);
          }
        }
      }
      if(digitalRead(4) == HIGH){
        for(byte i=6; i<9; i++){
          if(digitalRead(i) == HIGH){
            input2*=10;
            input2+=(i+1);
          }
        }
      }
      if(digitalRead(5) == HIGH);
      input2*=10;
    }
    while(digitalRead(2) == HIGH || digitalRead(3) == HIGH || digitalRead(4) == HIGH || digitalRead(5) == HIGH || digitalRead(6) == HIGH || digitalRead(7) == HIGH || digitalRead(8) == HIGH || digitalRead(9) == HIGH){}
    first_number = 1;//Setting first_number to TRUE so that
  }                     //we know the first number was written.
  if (first_number == 1 && second_number == 0) { //Checking if the first number was written and the second wasn't
    if(digitalRead(9) == 1){
      for (byte i = 2; i < 6; i++) {
        int a2=i-1;
        if (digitalRead(i, HIGH)) { //Setting the operation to the corresponding operation
          operation = a2;     //according to the button pressed
        }
      }
    }else{
      operation=5;
    }
  }
  if (second_number == 1) { //Checking if the second number was written
    if(digitalRead(9) == 1){
      for (int i = 2; i < 6; i++) { //Checking if another operation has to be done
        if (digitalRead(i, HIGH)) {
          if (operation == 1); //Calculating the result
          output = input1 + input2;
          if (operation == 2);
          output = input1 - input2;
          if (operation == 3);
          output = input1 * input2;
          if (operation == 4);
          output = input1 / input2;
          if (operation == 5){
          for (byte i = 1; i < (input2); i++){
              input1 = input1 * input1;
          }
            output=input1;
          }
          Serial.println(output);//Printing the output
          input1 = output;//Setting the first input to the output since another operation is done and
          input2 = 0;     //so only the second input is reset and it's going to be the only one used
          output = 0;//the output is reset after input1 was set to it so input isn't 0 unless the output was zero
          operation = (i - 1); //Setting the operation according to the button pressed
          first_number = 1;//Telling that the first number is typed since another operation is done
          second_number = 0;//Resetting second_number because it's going to be used
        }
      }
    }else if(digitalRead(6) == 1){
      if (operation == 1); //Calculating the result
      output = input1 + input2;
      if (operation == 2);
      output = input1 - input2;
      if (operation == 3);
      output = input1 * input2;
      if (operation == 4);
      output = input1 / input2;
      if (operation == 5){
         for (byte i = 1; i < (input2); i++){
           input1 = input1 * input1;
         }
        output=input1;
      }
      Serial.println(output);//Printing the output
      input1 = output;//Setting the first input to the output since another operation is done and
      input2 = 0;     //so only the second input is reset and it's going to be the only one used
      output = 0;//the output is reset after input1 was set to it so input isn't 0 unless the output was zero
      operation = 5; //Setting the operation according to the button pressed
      first_number = 1;//Telling that the first number is typed since another operation is done
      second_number = 0;//Resetting second_number because it's going to be used
     
    }else if(digitalRead(8, HIGH)) { //Checking if equals(=) was pressed
      if (operation == 1); //Calculating the result
      output = input1 + input2;
      if (operation == 2);
      output = input1 - input2;
      if (operation == 3);
      output = input1 * input2;
      if (operation == 4);
      output = input1 / input2;
      if (operation == 5){
         for (byte i = 1; i < (input2); i++){
           input1 = input1 * input1;
         }
        output=input1;
      }
      Serial.println(output);//Printing the output
      input1 = 0;//Resetting everything
      input2 = 0;
      output = 0;
      first_number = 0;
      second_number = 0;
      operation = 0;
    }
  }
  delay(10);//Delay in between reads for stability
}
)
Title: Re: I keep getting this error message and I don't know what causes it
Post by: UKHeliBob on Aug 02, 2020, 09:36 am
Code: [Select]
if (digitalRead(i, HIGH))
digitalRead() take one parameter, the pin number

You probably meant
Code: [Select]

if (digitalRead(i) == HIGH)
Title: Re: I keep getting this error message and I don't know what causes it
Post by: ChallengingRiptide on Aug 02, 2020, 09:38 am
Thanks! I seriously didn't notice that. I was mostly trying to understand the error message.
Title: Re: I keep getting this error message and I don't know what causes it
Post by: UKHeliBob on Aug 02, 2020, 09:43 am
Quote
I was mostly trying to understand the error message.
Code: [Select]
too many arguments to function 'int digitalRead(uint8_t)
I don't know how much more specific it could have been
Title: Re: I keep getting this error message and I don't know what causes it
Post by: slipstick on Aug 02, 2020, 10:01 am
The error message says that digitalRead takes one argument and you have tried to use more than one. That's very clear as compiler errors go. Some are a lot more difficult to interpret.

Steve
Title: Re: I keep getting this error message and I don't know what causes it
Post by: TheMemberFormerlyKnownAsAWOL on Aug 02, 2020, 11:51 am
Code: [Select]
if(digitalRead(9) == HIGH); Oops
Title: Re: I keep getting this error message and I don't know what causes it
Post by: J-M-L on Aug 02, 2020, 02:36 pm
Code: [Select]
if(digitalRead(9) == HIGH); Oops
to help OP a bit more:
if(digitalRead(9) == HIGH);
Oops
Title: Re: I keep getting this error message and I don't know what causes it
Post by: TheMemberFormerlyKnownAsAWOL on Aug 02, 2020, 02:52 pm
If you insist
if(digitalRead(9) == HIGH);
Title: Re: I keep getting this error message and I don't know what causes it
Post by: J-M-L on Aug 02, 2020, 03:08 pm
;
dot divided by coma ? :)

Title: Re: I keep getting this error message and I don't know what causes it
Post by: TomGeorge on Aug 03, 2020, 10:48 am
Hi,
Code: [Select]
if(digitalRead(9) == HIGH);
should be;
Code: [Select]
if(digitalRead(9) == HIGH)
Tom... :)
Title: Re: I keep getting this error message and I don't know what causes it
Post by: Deva_Rishi on Aug 03, 2020, 08:53 pm
Code: [Select]
90:32: errorso look on line 90... you can turn on linenrs showing in the IDE in preferences