forked from StRobertCHSCS/ICS4U-PCP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDistance Slow Down
More file actions
43 lines (38 loc) · 1.33 KB
/
Distance Slow Down
File metadata and controls
43 lines (38 loc) · 1.33 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
#pragma config(Sensor, port3, bumper, sensorVexIQ_Touch)
#pragma config(Sensor, port4, distance, sensorVexIQ_Distance)
#pragma config(Sensor, port10, colour, sensorVexIQ_LED)
#pragma config(Motor, motor1, left, tmotorVexIQ, PIDControl, driveLeft, encoder)
#pragma config(Motor, motor6, right, tmotorVexIQ, PIDControl, reversed, driveRight, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main()
{
while(true)
{
setMultipleMotors(100, left, right);
while (getDistanceValue(distance) <= 400 && getDistanceValue(distance) > 300)
{
setMultipleMotors(50, left, right);
setTouchLEDColor(colour, colorRed);
}
while (getDistanceValue(distance) <= 300 && getDistanceValue(distance) > 200)
{
setMultipleMotors(40, left, right);
setTouchLEDColor(colour, colorBlue);
}
while (getDistanceValue(distance) <= 200 && getDistanceValue(distance) > 100)
{
setMultipleMotors(20, left, right);
setTouchLEDColor(colour, colorGreen);
}
while (getDistanceValue(distance) <= 100 && getDistanceValue(distance) > 50)
{
setMultipleMotors(10, left, right);
if (getBumperValue(bumper) == 1)
{
backward(180, degrees, -50);
turnLeft(240, degrees, 100);
setTouchLEDColor(colour, colorYellow);
}
}
}
}