0% found this document useful (0 votes)
26 views1 page

Line Foll

The document initializes sensor and motor pin variables and assigns them pin numbers. It then sets the pins as inputs or outputs and reads the sensor values in a loop to control the motors accordingly.

Uploaded by

AakashSingh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views1 page

Line Foll

The document initializes sensor and motor pin variables and assigns them pin numbers. It then sets the pins as inputs or outputs and reads the sensor values in a loop to control the motors accordingly.

Uploaded by

AakashSingh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

//initializations of the sensor and output to moter

int
int
int
int
int
int

Lsensor
Rsensor
LmotorA
LmotorB
RmotorA
RmotorB

=
=
=
=
=
=

2;
3;
8;
9;
10;
11;

int LSvalue;
int RSvalue;
void setup()
{pinMode(Lsensor,INPUT);
pinMode(Rsensor,INPUT);
pinMode(LmotorA,OUTPUT);
pinMode(LmotorB,OUTPUT);
pinMode(RmotorA,OUTPUT);
pinMode(RmotorB,OUTPUT);
}
void loop()
{ LSvalue=digitalRead(Lsensor);
RSvalue=digitalRead(Rsensor);
if(LSvalue==LOW && RSvalue==LOW)
{ digitalWrite(LmotorA,HIGH);
digitalWrite(LmotorB,LOW);
digitalWrite(RmotorA,LOW);
digitalWrite(RmotorB,HIGH);
}
else if(LSvalue==LOW && RSvalue==HIGH)
{ digitalWrite(LmotorA,HIGH);
digitalWrite(LmotorB,LOW);
digitalWrite(RmotorA,LOW);
digitalWrite(RmotorB,LOW);
}
else if(LSvalue==HIGH && RSvalue==LOW)
{ digitalWrite(LmotorA,LOW);
digitalWrite(LmotorB,LOW);
digitalWrite(RmotorA,HIGH);
digitalWrite(RmotorB,LOW);
}
else if(LSvalue==HIGH && RSvalue==HIGH)
{ digitalWrite(LmotorA,LOW);
digitalWrite(LmotorB,LOW);
digitalWrite(RmotorA,LOW);
digitalWrite(RmotorB,LOW);
}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy