So basically we are supposed to build a conveyor belt with 3 automatic stops with 2 different types of sensors. It also has to be started by a bumpswitch and there must be an emergency stop button to stop the operations.
The sensors that we are going to use are two line followers and a light sensor, supposedly controlled by a flashlight.
Current issues:
-
lines with pause() has a error that reads “Unexpected ‘)’ during phrasing”, which I have no idea what it’s about.
-
I don’t know how to implement the flashlight with the line sensor in order to make it stop at the appropriate time.
Note: the threshold values for all analog sensors are denoted by three asterisks “*” because we have not calculated the threshold values yet.
#pragma config(Sensor, in1, LightSensor, sensorReflection)
#pragma config(Sensor, in2, LineF1, sensorLineFollower)
#pragma config(Sensor, in3, LineF2, sensorLineFollower)
#pragma config(Sensor, dgtl1, BumpStart, sensorTouch)
#pragma config(Sensor, dgtl2, BumpStop, sensorTouch)
#pragma config(Motor, port2, Motor1, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port10, FlashLight, tmotorVexFlashlight, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
void run()
{startMotor(Motor1,20);
}
void pause_1()
{stopMotor(Motor1);
wait(10);
startMotor(Motor1, 20);
wait(2);
}
task e_stop()
{
while(true)
{
if(SensorValue(BumpStop) == 1)
{
stopAllTasks(); // this ends the program
}
wait1Msec(10); // this prevents the current task from hogging the CPU
}
}
task main()
{ startTask(e_stop);
untilBump(BumpStart);
{
while(1==1)
{ run();
if(SensorValue(LineF2)>= ***)
{pause_1();
turnFlashlightOn(FlashLight, -120);
wait(10);
turnFlashlightOff(FlashLight);
}
if(SensorValue(LineF1)>= ***)
{pause_1();
}
if(SensorValue(LightSensor) >= ***)
{pause_1();
}