-
Notifications
You must be signed in to change notification settings - Fork 0
/
2SensorAuto.c
56 lines (50 loc) · 1.44 KB
/
2SensorAuto.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
#pragma config(Sensor, dgtl2, irLeft, sensorDigitalIn)
#pragma config(Sensor, dgtl3, irRight, sensorDigitalIn)
#pragma config(Motor, port2, motorLeft, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port3, servo, tmotorServoStandard, openLoop)
#pragma config(Motor, port9, motorRight, tmotorServoContinuousRotation, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
int getIrReading(tSensors irReceiverPin)
{
wait1Msec(1);
int ir = SensorValue[irReceiverPin];
wait1Msec(1);
return ir;
}
task main()
{
while (true)
{
if(vexRT[Btn7U] == 1){
motor[servo] = -128;
}
else if(vexRT[Btn7D] == 1){
motor[servo] = 128;
}
motor[motorLeft] = vexRT[Ch3];//Left Joystick Up/Down
motor[motorRight] = vexRT[Ch2];//Right Joystick Up/Down
//motor[motorLeft] = (vexRT[Ch3])(vexRT[Ch3]) * 100;
//motor[motorRight] = (-(vexRT[Ch3])(vexRT[Ch3]) * 100;
if (vexRT[Btn8D] == 1)
{
while (true)
{
if (getIrReading(irLeft) == 1 && getIrReading(irRight) == 1)
{
motor[motorLeft] = 50;
motor[motorRight] = 50;
}
else if (getIrReading(irLeft) == 0)
{
motor[motorLeft] = -30;
motor[motorRight] = 30;
}
else if (getIrReading(irRight) == 0)
{
motor[motorLeft] = 30;
motor[motorRight] = -30;
}
}
}
}
}