-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrobo500lvl4.c
28 lines (27 loc) · 1.07 KB
/
robo500lvl4.c
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
#pragma config(Sensor, S1, touchSensor, sensorTouch)
#pragma config(Sensor, S2, compassSensor, sensorVirtualCompass)
#pragma config(Sensor, S3, lightSensor, sensorLightActive)
#pragma config(Sensor, S4, sonarSensor, sensorSONAR)
#pragma config(Motor, motorA, gripperMotor, tmotorNormal, PIDControl, encoder)
#pragma config(Motor, motorB, rightMotor, tmotorNormal, PIDControl, encoder)
#pragma config(Motor, motorC, leftMotor, tmotorNormal, PIDControl, encoder)
task main()
{
for(int repeats = 0; repeats <= 8; repeats++) {
if (SensorValue(lightSensor) > 20) {
displayTextLine(2, "Moving Forward...");
motor[motorC] = 100;
motor[motorB] = 100;
wait1Msec(1900);
}
else {
motor[motorC] = 100;
motor[motorB] = 100;
wait1Msec(200);
displayTextLine(2, "Turning Right");
motor[motorC] = -100;
motor[motorB] = -100;
wait1Msec(1000);
}
}
}