How to fix "too many arguments"

this is my first project in coding and i got an error saying too many arguments to function sense

here is my code

#include <Servo.h>
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 8
#define RST_PIN 7
 

 // indcluding stuff basically naming stuff
MFRC522 rfid(SS_PIN, RST_PIN); // Instance of the class
MFRC522::MIFARE_Key key; 
const int IN1_PIN_FR = 5;    // Connect IN1 to digital pin 5
const int IN2_PIN_RR = 3;    // Connect IN2 to digital pin 3
const int ENA_PIN = 11; 
const int LEFT_IR_PIN = 2; // line sensor 
Servo myservo;            
Servo myservo2;
Servo myservo3;
int lineValue;
const int LINE_THRESHOLD = 500; 


void setup() {// setting up stuf using the named stuff
  SPI.begin(); // Init SPI bus
  rfid.PCD_Init(); 
  myservo.attach(9);
  myservo2.attach(10);
  myservo3.attach(11); // attaches the servo on pin 9 to the servo object
  pinMode(IN1_PIN_FR, OUTPUT );
  pinMode(IN2_PIN_RR, OUTPUT);
  
  // Initialize ENA and ENB pins as output
  pinMode(ENA_PIN, OUTPUT);
  

  Serial.begin(9600);
}
 // idk what this means butu i saw it in a book


void loop() {
  
   if ( ! rfid.PICC_IsNewCardPresent())
    return;

  if ( ! rfid.PICC_ReadCardSerial())
    return;

  
 MFRC522::PICC_Type piccType = rfid.PICC_GetType(rfid.uid.sak);
 
  Serial.print(F("RFID Tag UID:"));
  sense(rfid.uid.uidByte, rfid.uid.size);
  Serial.println("");
 
  rfid.PICC_HaltA();
    
  myservo.write(180);myservo2.write(180);myservo3.write(180);
  delay(100);                       // waits 1000ms for the servo to reach the position
  myservo.write(0);myservo2.write(0);myservo3.write(0);            // tell servo to go to position 0 degrees
  delay(100);                       // waits 1000ms for the servo to reach the position
  
}


void sense(){
  int leftSensorValue = digitalRead(LEFT_IR_PIN);
 
  // Check if both sensors detect the black line
  if (leftSensorValue == HIGH) {
    // Move forward

  digitalWrite(IN1_PIN_FR, HIGH);
  digitalWrite(IN2_PIN_RR, LOW);
  delay(1000);

  digitalWrite(IN1_PIN_FR, LOW);
  digitalWrite(IN2_PIN_RR, LOW);
  delay(1000);

  digitalWrite(IN1_PIN_FR, LOW);
  digitalWrite(IN2_PIN_RR, HIGH);
  delay(1000);

  digitalWrite(IN1_PIN_FR, HIGH);
  digitalWrite(IN2_PIN_RR, HIGH);
  delay(1000);

  
  analogWrite(ENA_PIN, 200);  // Set ENA speed to maximum
    // Set ENB speed to maximum
  }
  // Check if both sensors do not detect the black line
  else if (leftSensorValue == LOW) {
    // Reverse
   digitalWrite(IN1_PIN_FR, LOW);
  digitalWrite(IN2_PIN_RR, HIGH);
  
  analogWrite(ENA_PIN, 200);
  }
}

the error says "too many arguments to function sense"

Your function “sense()

Has no parameters or inputs.
But, you are calling it here with several inputs.
How do you put an item in a box with no holes..?

The sense() function is defined like this

void sense()
{

It takes no arguments. However, when you call it you do this

    sense(rfid.uid.uidByte, rfid.uid.size);

Hence the error

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.