
Help with my program please.
This is turning into the longest program I've written by myself, as a beginner programmer I'm having some difficulties with the syntax and compiling the program. If anyone could suggest ways to fix my program please let me know. Below is the program I have right now.
 |  |  |
 | Code: #pragma config(I2C_Usage, I2C1, i2cSensors) #pragma config(Sensor, dgtl1, limitswitch, sensorTouch) #pragma config(Sensor, dgtl2, sonarSensor, sensorSONAR_cm) #pragma config(Sensor, I2C_1, rightEncoder, sensorQuadEncoderOnI2CPort, , AutoAssign) #pragma config(Sensor, I2C_2, leftEncoder, sensorQuadEncoderOnI2CPort, , AutoAssign) #pragma config(Motor, port2, rightMotor, tmotorVex393, openLoop) #pragma config(Motor, port3, leftMotor, tmotorVex393, openLoop, reversed) #pragma config(Motor, port8, armMotor, tmotorVex393, openLoop) #pragma config(Motor, port9, clawMotor, tmotorVex393, openLoop) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
void moveStraight() { if(SensorValue[leftEncoder] > SensorValue[rightEncoder] { motor[rightMotor] = 63; motor[leftMotor] = 50; } if(SensorValue[rightEncoder] > SensorValue[leftEncoder]) { motor[rightMotor] = 50; motor[leftMotor] = 63; if(SensorValue[leftEncoder] == SensorValue[rightEncoder]) { motor[rightMotor] = 63; motor[leftMotor] = 63: }
void grab() { if (limitswitch == 1) { motor[clawMotor] = 27; wait1Msec(500); } while(SensorValue(sonarSensor) > 20 || SensorValue(sonarSensor) == -1) motor[rightMotor] = 63; motor[leftMotor] = 63; }
void drop() { motor[armMotor] = 127; wait1Msec(5000); while(SensorValue(sonarSensor) > 10 || SensorValue(sonarSensor) == -1) { motor[rightMotor] = 63; motor[leftMotor] = 63; } motor[clawMotor] = -127; wait1Msec(500) }
task main() {
SensorValue[rightEncoder] = 0; SensorValue[leftEncoder] = 0;
while( limitswitch == 0 ) { moveStraight(); } else clawMotor = 127; } |  |
 |  |  |
Here are error messages I'm receiving.
File "RobotMaze6-5-12.c" compiled on Jun 10 2012 16:43:38
15: *Warning*:expecting '[' and found '{'. Typing error assumed and '[' used.
16: *Warning*:Assignment '=' embedded in expression
16: **Error**:Missing ']' before ';'
20: **Error**:Ummatched left brace '{'
27: *Warning*:':' found instead of ';'. Typing error?
31: **Error**:Functions must be defined at main scope level
31: *Warning*:Unreferenced function 'grab'
33: *Warning*:Mismatched typedefs. Converting typedef 'short' to typedef 'tSensors', value 'in2'
44: **Error**:Functions must be defined at main scope level
44: *Warning*:Unreferenced function 'drop'
54: *Warning*:';' expected before '}'. Automatically inserted by compiler
57: **Error**:Task 'main' is not defined at global scope level
57: **Error**:Tasks must be defined at main scope level
63: *Warning*:Mismatched typedefs. Converting typedef 'short' to typedef 'tSensors', value 'in1'
68: **Error**:Unexpected 'else'. Ignored.
69: **Error**:Unexpected scanner token-> 'clawMotor'
69: **Error**:Unexpected scanner token-> '='
69: **Error**:Unexpected scanner token-> '127'
70: **Error**:Expected->'}'. Found 'EOF'
70: **Error**:Executable statements not valid in 'main' declaration block
Thanks again to anyone who is willing to help!