error with void pin mode

So I am trying to make a line follower robot with simple code. Here is how far i have reached

int ir1 = A0;
int ir2 = A1;
int motor1 = 4;
int motor2 = 5;
int motor3 = 6;
int motor4 = 7;

void setup() {
  // put your setup code here, to run once:
  pinMode (ir1 = INPUT);
  pinMode (ir2= INPUT);
  pinMode (motor1 = OUTPUT);
  pinMode (motor2 = OUTPUT);
  pinMode (motor3 = OUTPUT);
  pinMode (motor4 = OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  if (ir1 = 1 && ir2 = 0)
  {
    digitalWrite (4, 1);
    digitalWrite (5, 0);
    digitalWrite (6, 0);
    digitalWrite (7, 1);
  }
  if (ir1 = 0 && ir2 = 1)
  {
    digitalWrite (4, 0);
    digitalWrite (5, 1);
    digitalWrite (6, 1);
    digitalWrite (7, 0);
  }



}

now it shows me an error saying too few arguments to function void pinMode
here is the message
Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: “Arduino Nano, ATmega328P (Old Bootloader)”

C:\Users\Admin\Documents\Arduino\irlol\irlol.ino: In function ‘void setup()’:

irlol:11:23: error: too few arguments to function ‘void pinMode(uint8_t, uint8_t)’

pinMode (ir1 = INPUT);

^

In file included from sketch\irlol.ino.cpp:1:0:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:133:6: note: declared here

void pinMode(uint8_t, uint8_t);

^

irlol:12:22: error: too few arguments to function ‘void pinMode(uint8_t, uint8_t)’

pinMode (ir2= INPUT);

^

In file included from sketch\irlol.ino.cpp:1:0:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:133:6: note: declared here

void pinMode(uint8_t, uint8_t);

^

irlol:13:27: error: too few arguments to function ‘void pinMode(uint8_t, uint8_t)’

pinMode (motor1 = OUTPUT);

^

In file included from sketch\irlol.ino.cpp:1:0:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:133:6: note: declared here

void pinMode(uint8_t, uint8_t);

^

irlol:14:27: error: too few arguments to function ‘void pinMode(uint8_t, uint8_t)’

pinMode (motor2 = OUTPUT);

^

In file included from sketch\irlol.ino.cpp:1:0:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:133:6: note: declared here

void pinMode(uint8_t, uint8_t);

^

irlol:15:27: error: too few arguments to function ‘void pinMode(uint8_t, uint8_t)’

pinMode (motor3 = OUTPUT);

^

In file included from sketch\irlol.ino.cpp:1:0:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:133:6: note: declared here

void pinMode(uint8_t, uint8_t);

^

irlol:16:27: error: too few arguments to function ‘void pinMode(uint8_t, uint8_t)’

pinMode (motor4 = OUTPUT);

^

In file included from sketch\irlol.ino.cpp:1:0:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:133:6: note: declared here

void pinMode(uint8_t, uint8_t);

^

C:\Users\Admin\Documents\Arduino\irlol\irlol.ino: In function ‘void loop()’:

irlol:21:22: error: lvalue required as left operand of assignment

if (ir1 = 1 && ir2 = 0)

^

irlol:28:22: error: lvalue required as left operand of assignment

if (ir1 = 0 && ir2 = 1)

^

exit status 1
too few arguments to function ‘void pinMode(uint8_t, uint8_t)’

requesting help asap. thank you

Have a look at the top of the page - Resources / Reference. You’ll find pinMode on that page and it will show you the correct syntax for using it. As the error says it wants 2 parameters, pin number and mode (no = sign).

And then in your ifs - = means assign a value, == means compare two things, which I guess is what you meant.

Programming languages are very fussy. You have to do things their way. You can’t just write whatever you feel like and expect the compiler to understand what you probably meant.

Steve

Hi,
https://www.arduino.cc/en/Reference.PinMode

https://www.arduino.cc/reference/en/language/structure/control-structure/if/

Tom... :slight_smile:

slipstick:
Have a look at the top of the page - Resources / Reference. You’ll find pinMode on that page and it will show you the correct syntax for using it. As the error says it wants 2 parameters, pin number and mode (no = sign).

Thank you very much. Im new to arduino and code and this totally slipped out of my mind.