Does anyone have sample code for sonar sensor using Robotc natural language for the IQ Clawbot?
#pragma config(Sensor, port2, touchLED, sensorVexIQ_LED)
#pragma config(Sensor, port3, colorDetector, sensorVexIQ_ColorHue)
#pragma config(Sensor, port4, gyroSensor, sensorVexIQ_Gyro)
#pragma config(Sensor, port7, distanceMM, sensorVexIQ_Distance)
#pragma config(Sensor, port8, bumpSwitch, sensorVexIQ_Touch)
#pragma config(Motor, motor1, leftMotor, tmotorVexIQ, openLoop, driveLeft, encoder)
#pragma config(Motor, motor6, rightMotor, tmotorVexIQ, openLoop, reversed, driveRight, encoder)
#pragma config(Motor, motor10, armMotor, tmotorVexIQ, openLoop, encoder)
#pragma config(Motor, motor11, clawMotor, tmotorVexIQ, openLoop, encoder)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//
task main()
{
setDistanceMaxRange(distanceMM, 100);
setDistanceMinRange(distanceMM, 25);
repeat (forever)
{
displaySensorValues(line1, distanceMM);
}
}
I just programmed something quick in Graphical RobotC and converted it to text. Hope this helps
Thanks…
We are trying to complete the obstacle avoidance challenge in VR worlds Challenge pack, using IQ and natural language Robot c.
So move fwd till, then back up and turn, was more what I was asking. If you have that, then that would be great.
Try this code:
#pragma config(Sensor, port2, touchLED, sensorVexIQ_LED)
#pragma config(Sensor, port3, colorDetector, sensorVexIQ_ColorHue)
#pragma config(Sensor, port4, gyroSensor, sensorVexIQ_Gyro)
#pragma config(Sensor, port7, distanceMM, sensorVexIQ_Distance)
#pragma config(Sensor, port8, bumpSwitch, sensorVexIQ_Touch)
#pragma config(Motor, motor1, leftMotor, tmotorVexIQ, openLoop, driveLeft, encoder)
#pragma config(Motor, motor6, rightMotor, tmotorVexIQ, openLoop, reversed, driveRight, encoder)
#pragma config(Motor, motor10, armMotor, tmotorVexIQ, openLoop, encoder)
#pragma config(Motor, motor11, clawMotor, tmotorVexIQ, openLoop, encoder)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//
task main()
{
setDistanceMaxRange(distanceMM, 100);
setDistanceMinRange(distanceMM, 25);
setMultipleMotors(50, leftMotor, rightMotor, noMotor, noMotor);
waitUntil (getDistanceValue(distanceMM) <= 40);
stopMultipleMotors(leftMotor, rightMotor, noMotor, noMotor);
backward(1, rotations, 50);
turnRight(1, rotations, 50);
}