getting error too few arguments .PLEASE HELP

I’m trying to make a position control of dc motor using pid controller .Here im using a pot in the feedback .

// PID motor position control.

#include <PID_v1.h>
#define enb           5
#define M1             7                       // PWM outputs to L298N H-Bridge motor driver module
#define M2             6
int DesiredValue;
int CurrentValue;
int pot;
//int Direction;
double kp = 5 , ki = 1 , kd = 0.01;             // modify for optimal performance
double input = 0, output = 0, setpoint = 0;
PID myPID(&input, &output, &setpoint, kp, ki, kd, DIRECT);  
void setup() {
        pinMode(enb, OUTPUT);
  pinMode(M2, OUTPUT);
  pinMode(M1, OUTPUT);

  myPID.SetOutputLimits(-255, 255);
  Serial.begin (9600);   

void loop() {
  setpoint =600;
  input =analogRead(A0);  
CurrentValue= input;
  // Serial.println(encoderPos);                     
  myPID.Compute();                                    // calculate new output
   Direction(output);                                   // drive L298N H-Bridge module

void Direction(int DesiredValue,int CurrentValue) 
{                                // to H-Bridge board
  if (DesiredValue>CurrentValue) 
digitalWrite(M1, LOW);
  digitalWrite(M2, HIGH); 

 if (DesiredValue< CurrentValue) //right  
  digitalWrite(M2, LOW);



error message:

too few arguments to function ‘void Direction(int, int)’

Here’s the function signature of the Direction function you defined:

void Direction(int DesiredValue,int CurrentValue)

As you can see, the function expects two arguments: DesiredValue and CurrentValue.

In your code, you call the Direction function like this:


As you can see, you are only providing a single argument to a function that takes two arguments. This is the cause of the error.

Please always do an Auto Format (Tools > Auto Format in the Arduino IDE or Ctrl + B in the Arduino Web Editor) on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read.

Please remove unnecessary blank lines from your code before posting to the forum. One or two to separate code into logical sections is fine but large spaces for no reason or random blank lines just make for more scrolling when we’re trying to read your code.