Hello forum users! I am new here and have a project due next week Monday, I have built a robot and coded it so that it can sort 3 types of marbles (Metal, wood and clear plastic) I am using a light sensor to differentiate between the 3. The values are as followed, Plastic = less then 600, Wood = between 600 and 1000 and metal = over 1000. I am trying to use if else else statements to achieve this. The sensor value determines the rotation of a servo with a plate on it for where the marbles should go… The code is in Vex Cortex 2.0 and PLTW Natural language and is available below. I get errors where both else statements appear. I have searched for the past 5 days trying to find a solution for myself but I have now realized I need more help.
#pragma config(Sensor, in1, Color, sensorReflection)
#pragma config(Sensor, dgtl1, Bump, sensorTouch)
#pragma config(Motor, port1, Light, tmotorVexFlashlight, openLoop, reversed)
#pragma config(Motor, port3, Gate, tmotorVex269_MC29, openLoop)
#pragma config(Motor, port4, Plate, tmotorServoStandard, openLoop)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//
task main()
{
turnFlashlightOn (Light, 127);
if (SensorValue (Bump) == 1) //If bump is pressed then program starts
{
while (1 == 1)
{
if (SensorValue (Light <= 600)) // If the light sensor is less then 600
setServo (Plate, -60); // The servo goes to -60
wait (1); //Gives servo time to move
startMotor (Gate, 25); //Starts gear to move marble in cup
wait (.5); // Lets motor push marble
stopMotor (Gate); //Stops motor
}
{
else if (SensorValue (Light =< 600 || <= 1000 )); //If the light sensor is greater then 600 or less then 1000
setServo (Plate, 1); // The servo goes to 1
wait (1); //Gives servo time to move
startMotor (Gate, 25); //Starts gear to move marble in cup
wait (.5); // Lets motor push marble
stopMotor (Gate); //Stops motor
}
else
{
if (SensorValue (Light >= 1000) //If the light sensor is greater then 1000
{
setServo (Plate, 80); // The server goes to 80
wait (1); //Gives servo time to move
startMotor (Gate, 25); //Starts gear to move marble in cup
wait (.5); // Lets motor push marble
stopMotor (Gate); //Stops motor
}
}
}
}
The errors I get are:
File “C:\Users\NAME\Desktop\Marble Sorter.c” compiled on May 09 2019 09:58:13
Warning:Mismatched typedefs. Converting typedef ‘short’ to typedef ‘tMotor’, value ‘0x0258’
Error:Unexpected ‘else’. Ignored.
Error:Unexpected ‘<’ during parsing
Error:Expected->‘)’. Found ‘||’
Error:Unexpected ‘<=’ during parsing
Error:Unexpected ‘)’ during parsing
Error:Unexpected ‘else’. Ignored.
Warning:Mismatched typedefs. Converting typedef ‘short’ to typedef ‘tMotor’, value ‘0x03E8’
Warning:Ummatched left parenthesis ‘(’ at end of line. Automatically inserted.