Go Down

Topic: I keep getting this error message and I don't know what causes it (Read 142 times) previous topic - next topic

ChallengingRiptide

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
}
)

UKHeliBob

Code: [Select]
if (digitalRead(i, HIGH))
digitalRead() take one parameter, the pin number

You probably meant
Code: [Select]

if (digitalRead(i) == HIGH)
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

ChallengingRiptide

Thanks! I seriously didn't notice that. I was mostly trying to understand the error message.

UKHeliBob

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
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

slipstick

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

TheMemberFormerlyKnownAsAWOL

Please don't PM technical questions - post them on the forum, then everyone benefits/suffers equally

J-M-L

Code: [Select]
if(digitalRead(9) == HIGH); Oops
to help OP a bit more:
if(digitalRead(9) == HIGH);
Oops
Hello - Please do not PM me for help,  others will benefit as well if you post your question publicly on the forums.
Bonjour Pas de messages privés SVP, postez dans le forum directement pour que ça profite à tous

TheMemberFormerlyKnownAsAWOL

#7
Aug 02, 2020, 02:52 pm Last Edit: Aug 02, 2020, 02:53 pm by TheMemberFormerlyKnownAsAWOL
If you insist
if(digitalRead(9) == HIGH);
Please don't PM technical questions - post them on the forum, then everyone benefits/suffers equally

J-M-L

Hello - Please do not PM me for help,  others will benefit as well if you post your question publicly on the forums.
Bonjour Pas de messages privés SVP, postez dans le forum directement pour que ça profite à tous

TomGeorge

Hi,
Code: [Select]
if(digitalRead(9) == HIGH);
should be;
Code: [Select]
if(digitalRead(9) == HIGH)
Tom... :)
Everything runs on smoke, let the smoke out, it stops running....

Deva_Rishi

Code: [Select]
90:32: errorso look on line 90... you can turn on linenrs showing in the IDE in preferences
To 'Correct' you have to be Correct. (and not be condescending..)

Go Up