-
Notifications
You must be signed in to change notification settings - Fork 0
/
sumo.c
35 lines (33 loc) · 703 Bytes
/
sumo.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
29
30
31
32
33
34
35
#pragma config(Sensor, S1, light, sensorLightActive)
/*Light on porn 1*/
#pragma config(Sensor, S2, sonar, sensorSONAR)
/*Sonar on port 2*/
task main()
{
while(true){
while(light < 50 /*White*/){
motor[motorA] = 100; /*Turn*/
wait1Msec(400);
}
motor[motorA] = -100;
motor[motorB] = -100;
if(sonar > 30){
stopMotor[motorA]
stopMotor[motorB]
motor[motorA] = -100;
motor[motorB] = -100;
}
else{
nMotorEncoder[motorA] = 0;
nMotorEncoder[motorB] = 0;
if (nMotorEncoder[motorA] < 1800){
motor[motorB] = -15;
motor[motorA] = 0;
}
ifelse (nMotorEncoder[motorB] < 1800)
{
motor[motorB] = 0;
motor[motorA] = -15;
}
}
}