-
Notifications
You must be signed in to change notification settings - Fork 2
/
TaskExample.c
60 lines (53 loc) · 1.46 KB
/
TaskExample.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#pragma config(Hubs, S1, HTMotor, HTMotor, none, none)
#pragma config(Sensor, S1, , sensorI2CMuxController)
#pragma config(Sensor, S2, IRSeeker, sensorHiTechnicIRSeeker1200)
#pragma config(Sensor, S3, light, sensorLightActive)
#pragma config(Sensor, S4, sonar, sensorSONAR)
#pragma config(Motor, mtr_S1_C1_1, rightMotor, tmotorTetrix, openLoop, reversed, encoder)
#pragma config(Motor, mtr_S1_C1_2, leftMotor, tmotorTetrix, openLoop, encoder)
#pragma config(Motor, mtr_S1_C2_1, armMotor, tmotorTetrix, openLoop, encoder)
#pragma config(Motor, mtr_S1_C2_2, intakeMotor, tmotorTetrix, openLoop, encoder)
bool intakeOn = false;
task runIntake()
{
intakeOn = true;
while(intakeOn)
{
motor[intakeMotor] = 100;
wait1Msec(1000);
}
motor[intakeMotor] = 0;
}
task report()
{
while(true)
{
eraseDisplay();
nxtDisplayString(1, "right = %d", motor[rightMotor]);
nxtDisplayString(2, "left = %d", motor[leftMotor]);
wait1Msec(100);
}
}
task main()
{
StartTask(runIntake);
StartTask(report);
int iterations = 0;
while(true)
{
// no reading, turn in place
motor[rightMotor] = 20;
motor[leftMotor] = 20;
wait1Msec(2000);
motor[rightMotor] = -20;
motor[leftMotor] = -20;
wait1Msec(2000);
iterations++;
if(iterations >= 3)
{
intakeOn = false;
}
}
motor[rightMotor] = 0;
motor[leftMotor] = 0;
}