Need a little help in my code

Im new to arduino and this stuff but i dont know why my code wont work ?

here is the code

int T = 5000;

void setup() { pinMode (2,OUTPUT); pinMode (3,OUTPUT); pinMode (4,OUTPUT); pinMode (5,OUTPUT); //Motor 1 is 2,3 //Motor 2 is 4,5

}

void backward () {

digitalWrite (2,HIGH); digitalWrite (3,LOW); digitalWrite (4,HIGH); digitalWrite (5,LOW);

}

void forward () {

digitalWrite (2,LOW); digitalWrite (3,HIGH); digitalWrite (4,LOW); digitalWrite (5,HIGH);

}

void loop() {

forward (T = 1000);

backward (T = 500);

forward (T = 1000);

}

and this is the error

error: too many arguments to function 'void forward()'

because you define it taking exactly zero arguments, yet you are passing it one!

void forward ()  //<<<<<<<<< takes no arguments!!!
{

digitalWrite (2,LOW);
digitalWrite (3,HIGH);
digitalWrite (4,LOW);
digitalWrite (5,HIGH);

}
forward (T = 1000); // <<<<<<<< passing one!!!

Why are you assigning a value to T when calling the function? Makes no sense.

because i want to make different times with the same variable how i can do it then ?

I would recommend reading the sticky forum posts (“How to use this forum” etc.) and learning more of the basics of C/C++ before going further.

The error message is correct, so to understand what it means it will be necessary to research what functions are, what their arguments are, how you pass values to them etc.

because i want to make different times with the same variable how i can do it then ?

T = 100;
forward(T);

T = 300;
backward(T);

But, this requires that the functions take an argument AND that they actually use the argument.

T should NOT be global.

PaulS:

T = 100;

forward(T);

T = 300;
backward(T);




But, this requires that the functions take an argument AND that they actually use the argument.

T should NOT be global.

oh i got it thanks :smiley: