You are on page 1of 3

#include<stdio.

h>
int main()
{
printf("this is line follower robot program\n");
int s1, s2, s3, s4, s5;
int HIGH = 1;
int LOW = 0;
int x;
printf("enter the value of sensor 1\n");
scanf_s("%d", &s1);
printf("enter the value of sensor 2\n");
scanf_s("%d", &s2);
printf("enter the value of sensor 3\n");
scanf_s("%d", &s3);
printf("enter the value of sensor 4\n");
scanf_s("%d", &s4);
printf("enter the value of sensor 5\n");
scanf_s("%d", &s5);
if (HIGH == s1 && HIGH == s2 && LOW == s3 && HIGH == s4 && HIGH == s5)
{
printf("movement forward\n");
printf("motor 1 is HIGH\n");
printf("motor 2 is HIGH\n");
printf("speed is fast\n");
}
else if (HIGH == s1 && HIGH == s2 && HIGH == s3 && LOW == s4 && HIGH == s5)
{
printf("movement is toword right turn\n");
printf("motor 1 is HIGH\n");
printf("motor 2 is LOW\n");
printf("speed is slow\n");
}
else if (HIGH == s1 && HIGH == s2 && HIGH == s3 && HIGH == s4 && LOW == s5)
{
printf("movement is toword right turn\n");
printf("motor 1 is HIGH\n");
printf("motor 2 is LOW\n");
printf("speed is slow\n");
}
else if (HIGH == s1 && LOW == s2 && HIGH == s3 && HIGH == s4 && HIGH == s5)
{
printf("movement is toword left turn\n");
printf("motor 1 is LOW\n");
printf("motor 2 is HIGH\n");
printf("speed is slow\n");
}
else if (HIGH == s1 && LOW == s2 && HIGH == s3 && HIGH == s4 && HIGH == s5)
{
printf("movement is toword left turn\n");
printf("motor 1 is LOW\n");
printf("motor 2 is HIGH\n");
printf("speed is slow\n");
}
else if (LOW == s1 && LOW == s2 && LOW == s3 && LOW == s4 && LOW == s5)
{
printf("movement is stopped\n");
printf("motor 1 is LOW\n");
printf("motor 2 is LOW\n");
printf("speed is slow\n");
}
else
{
printf("nothing\n");
}
scanf_s("%d", &x);
return 0;

#include<stdio.h>
int main()
{
printf("this is line follower robot program\n");

int s1, s2, s3, s4, s5;


int HIGH = 1;
int LOW = 0;
int x;
int a = 0;
printf("enter the value of sensor 1\n");
scanf_s("%d", &s1);
printf("enter the value of sensor 2\n");
scanf_s("%d", &s2);
printf("enter the value of sensor 3\n");
scanf_s("%d", &s3);
printf("enter the value of sensor 4\n");
scanf_s("%d", &s4);
printf("enter the value of sensor 5\n");
scanf_s("%d", &s5);

if (HIGH == s1 && HIGH == s2 && LOW == s3 && HIGH == s4 && HIGH ==


s5)
{
printf("movement forward\n");
printf("motor 1 is HIGH\n");
printf("motor 2 is HIGH\n");
printf("speed is fast\n");
}
else if (HIGH == s1 && HIGH == s2 && HIGH == s3 && LOW == s4 && HIGH
== s5)
{
printf("movement is toword right turn\n");
printf("motor 1 is HIGH\n");
printf("motor 2 is LOW\n");
printf("speed is slow\n");
}
else if (HIGH == s1 && HIGH == s2 && HIGH == s3 && HIGH == s4 && LOW
== s5)
{
printf("movement is toword right turn\n");
printf("motor 1 is HIGH\n");
printf("motor 2 is LOW\n");
printf("speed is slow\n");
}
else if (HIGH == s1 && LOW == s2 && HIGH == s3 && HIGH == s4 && HIGH
== s5)
{
printf("movement is toword left turn\n");
printf("motor 1 is LOW\n");
printf("motor 2 is HIGH\n");
printf("speed is slow\n");
}
else if (HIGH == s1 && LOW == s2 && HIGH == s3 && HIGH == s4 && HIGH
== s5)
{
printf("movement is toword left turn\n");
printf("motor 1 is LOW\n");
printf("motor 2 is HIGH\n");
printf("speed is slow\n");
}
else if (LOW == s1 && LOW == s2 && LOW == s3 && LOW == s4 && LOW ==
s5)
{
printf("movement is stopped\n");
printf("motor 1 is LOW\n");
printf("motor 2 is LOW\n");
printf("speed is slow\n");
}
else
{
printf("enter invalid entry\n");
}

do{

a = a + 1;
} while (a < 5);

scanf_s("%d", &x);
return 0;
}

You might also like