New to coding please help me in the error

/------ Program for Obstrucle Robot using Arduino----- */ /-------definning Inputs------*/

define LS 4 // left sensor

define RS 5 // right sensor

/-------definning Outputs------/

define LM1 8 // left motor

define LM2 9 // left motor

define RM1 10 // right motor

define RM2 11 // right motor

void setup() { pinMode(LS, INPUT); pinMode(RS, INPUT); pinMode(LM1, OUTPUT); pinMode(LM2, OUTPUT); pinMode(RM1, OUTPUT); pinMode(RM2, OUTPUT);

}

void loop() {{ if (digitalRead((LS==LOW)&&(RS==LOW))) Forward(); } { if (digitalRead((LS==HIGH)&&(RS==LOW)))// put your main code here, to run repeatedly: Left(); } { if (digitalRead((LS==LOW)&&(RS==HIGH))) Right(); }

{if (digitalRead((LS==HIGH)&&(RS==HIGH)))

Reverse(); delay (100); Right(); delay (100); } } void Forward() { digitalWrite(LM1, HIGH); digitalWrite(LM2, LOW); digitalWrite(RM1, HIGH); digitalWrite(RM2, LOW); } void Reverse() { digitalWrite(LM1, LOW); digitalWrite(LM2, HIGH); digitalWrite(RM1, LOW); digitalWrite(RM2, HIGH); } void Right() { digitalWrite(LM1, HIGH); digitalWrite(LM2, LOW); digitalWrite(RM1, LOW); digitalWrite(RM2, HIGH); } void Left() { digitalWrite(LM1, LOW); digitalWrite(LM2, HIGH); digitalWrite(RM1, HIGH); digitalWrite(RM2, LOW);

}

Hi, Welcome to the forum.

Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code. It will be formatted in a scrolling window that makes it easier to read.

Please tell us what it is supposed to do and what it is doing. What model arduino are you using and what version IDE.

Thanks.. Tom... :)

 if ( digitalRead(LS==LOW)&&digitalRead(RS==LOW))

Nonsense. Pay attention to where the parentheses go.

Pay attention to how to call functions.

Pay attention to how to define functions.

Hi, pauls thanks for your suggestion but I don't know how to call function and how to define function can you please help me. thanks

I am using Arduino UNO board
my code is compiling but not giving the output as I expected please help me. I have attached the code below.
Thanks

ob_code.ino (1.26 KB)

Fix the indicated lines to start, as has been pointed out already

/*------ Program for Line Follower Robot using Arduino----- */

 

/*-------definning Inputs------*/

 

const int LS=4; // left sensor

 

const int RS=5; // right sensor

 

/*-------definning Outputs------*/

 

const int LM1=8; // left motor

 

const int LM2=9; // left motor

 

const int RM1=10; // right motor

 

const int RM2=11; // right motor

 

 

 

void setup()

 

{

 

 pinMode(4, INPUT);

 

 pinMode(5, INPUT);

 

 pinMode(8, OUTPUT);

 

 pinMode(9, OUTPUT);

 

 pinMode(10, OUTPUT);

 

 pinMode(11, OUTPUT);

 

 

 

}

 

 

 

void loop() {{ << extra { here is not needed

 

 if(digitalRead(("LS==LOW")&&("RS==LOW"))) << Fix this: if( (digitalRead(LS)==LOW) && (digitalRead(RS)==LOW) )

 { << brace needed here

 Forward();

} << to go with this one

 

{ << wrong place

 

 if (digitalRead(("LS==HIGH")&&("RS==LOW"))) << same fix as above

 { << goes here

 Left();

 

}

 

{ << same

 

if (digitalRead(("LS==LOW")&&("RS==HIGH"))) << same fix as above

 

Right();

 

}

 

 

 

{ << same

 

 if (digitalRead(("LS==HIGH")&&("RS==HIGH"))) << same fix as above

 { // here

Reverse();

} // and here

other similar stuff may need fixing in the functions calls

Thank you very much crossroads it's working.