How to write a C Program to Find The Line in C Programming Language ?
Solution For C Program:
void FindTheLine();
task main()
{
int left = -60 // servo positions
int right = 60
untilBump(bumpSwitch) // start the program
{
turnFlashLghtOn(flashLight, 127) // flashlight for line following
startTask(SuperCoolLED) // turn in blinking leds
FindTheLine(); // find the line before following it
while(true) // follow the line
{
}
}
}
task SuperCoolLED() // looks cool
{
while(true)
{
turnLEDOn(LED1);
wait(.1);
turnLEDOff(LED1);
turnLEDOn(LED2);
wait(.1);
turnLEDOff(LED2);
turnLEDOn(LED3);
wait(.1);
turnLEDOff(LED3);
turnLEDOn(LED4);
wait(.1);
turnLEDOff(LED4);
turnLEDOn(LED5);
wait(.1);
turnLEDOff(LED5);
}
}
void FindTheLine() // drives forward until it finds the line
{
startMotor(driveMotor, 60);
while(true)
{
if sensorvalue(lineFollower1 ?? something) // detects line
{
stopMotor(driveMotor); // stops motor when it finds the line
break; // stops the while loop and completes the function
}
if sensorvalue(lineFollower2 ?? something)
{
stopMotor(driveMotor);
break;
}
if sensorvalue(lineFollower3 ?? something)
{
stopMotor(driveMotor);
break;
}
}
}