forked from StRobertCHSCS/ICS4U-PCP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode
More file actions
52 lines (51 loc) · 1.47 KB
/
code
File metadata and controls
52 lines (51 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#pragma config(Sensor, port2, gyro_sensor, sensorVexIQ_Gyro)
#pragma config(Sensor, port3, bumper_sensor, sensorVexIQ_Touch)
#pragma config(Sensor, port4, colour_sensor, sensorVexIQ_Color12Color)
#pragma config(Sensor, port5, distance_sensor, sensorVexIQ_Distance)
#pragma config(Sensor, port7, touch_led, sensorVexIQ_LED)
#pragma config(Motor, motor1, left_motor, tmotorVexIQ, PIDControl, driveLeft, encoder)
#pragma config(Motor, motor6, right_motor, tmotorVexIQ, PIDControl, reversed, driveRight, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main()
{
bool finish = true;
while (finish)
{
if (getTouchLEDValue(touch_led) == 1)
{
while (getTouchLEDValue(touch_led) == 0)
{
setMultipleMotors(75, left_motor, right_motor);
if (getColorName(colour_sensor) == colorRed)
{
finish = false;
}
if (getBumperValue(bumper_sensor) == 1)
{
if (getDistanceValue(distance_sensor) < 350)
{
backward(90,degrees, 50);
resetGyro(gyro_sensor);
while (getGyroDegrees(gyro_sensor) < 80)
{
setMotor(left_motor, -50);
setMotor(right_motor, 50);
}
stopAllMotors();
}
else
{
backward(90,degrees, 50);
resetGyro(gyro_sensor);
while(getGyroDegrees(gyro_sensor) > -80)
{
setMotor(left_motor, 50);
setMotor(right_motor, -50);
}
stopAllMotors();
}
}
}
}
}
}