IR Sensor coding

I have made a LINE Follower bot but I think the coding is wrong. I have used pin 4,5,6,7 for motors and 0,1 pins for sensor
Int x;
Int y;
Void setup(){
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT):
}
Void loop(){
x=analogRead(0);
y=analogRead(1);
If (x>300 &&y>>300){
Digitalwrite(4,HIGH);
Digitalwrite(5,LOW);
Digitalwrite(6,HIGH);
Digitalwrite(7,LOW);
}
else if (x<300 && y>300){
//Turn RIGHT}
else if (x>300 && y<300){
//Turn LEFT}
else (x<300 && y<300){
//MOVE FORWARD}
}

Welcome to the forum AgarwalSukant (glad I don't have to pronounce that :) )

Its traditional here to give you a hard time for not using code tags. See this post to save yourself some hassle. How to use this forum

This is how it should look when you do use them

If (x>300 &&y>>300){

You may also notice where you went wrong in this line.

Yawn

  1. Always post code in code tags

  2. Always use the auto format tool before posting

  3. At least try and compile the code before posting

THE FORUM POSTING RULES ARE AT THE TOP OF THE FORUM - THEY APPLY TO YOU AND TO EVERY ONE ELSE.

Mark

What they said ^.

Also, “void” is always typed in lower-case, not with an upper-case ‘V’.:-

Void setup()
.
.
.
Void loop()

should be:-

void setup()
.
.
.
void loop()

Same goes for “int”:-

Int x;
Int y;

should be:-

int x;
int y;

And this should end in a semi-colon, not a colon:-

pinMode(7, OUTPUT):

And these:-

Digitalwrite(4, HIGH);

should look like this:-

digitalWrite(4, HIGH);

You’re missing an ‘if’ and some closing brackets, too, as well as starting one ‘if’ with an upper-case ‘I’.

I’d suggest that you have a closer look at the examples supplied with the IDE, then take much more care when writing your code.

I haven’t checked the logic of your code, so have no idea if it will work when you finish writing it, but here’s the repaired version, that actually compiles:-

int x;
int y;
void setup()
{
    pinMode(4, OUTPUT);
    pinMode(5, OUTPUT);
    pinMode(6, OUTPUT);
    pinMode(7, OUTPUT);
}

void loop()
{
    x = analogRead(0);
    y = analogRead(1);
    if (x > 300 && y > 300)
    {
        digitalWrite(4, HIGH);
        digitalWrite(5, LOW);
        digitalWrite(6, HIGH);
        digitalWrite(7, LOW);
    }
    else if (x < 300 && y > 300)
    {
        //Turn RIGHT
    }
    else if (x > 300 && y < 300)
    {
        //Turn LEFT
    }
    else if (x < 300 && y < 300)
    {
        //MOVE FORWARD
    }
}