-
Notifications
You must be signed in to change notification settings - Fork 0
/
BackwardsIRseeker1_2013 (Tim Garnto's conflicted copy 2014-01-18).c
60 lines (53 loc) · 2.35 KB
/
BackwardsIRseeker1_2013 (Tim Garnto's conflicted copy 2014-01-18).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(Hubs, S4, HTServo, HTMotor, none, none)
#pragma config(Sensor, S2, touch, sensorTouch)
#pragma config(Sensor, S3, IRSEEKER, sensorI2CCustom)
#pragma config(Motor, motorA, , tmotorNXT, openLoop, encoder)
#pragma config(Motor, motorB, , tmotorNXT, openLoop, encoder)
#pragma config(Motor, motorC, , tmotorNXT, openLoop, encoder)
#pragma config(Motor, mtr_S1_C1_1, motor_left, tmotorTetrix, openLoop, reversed)
#pragma config(Motor, mtr_S1_C1_2, motor_right, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C2_1, motorLift, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C2_2, motorFlag, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S4_C2_1, motorFly, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S4_C2_2, motorI, tmotorTetrix, openLoop)
#pragma config(Servo, srvo_S4_C1_1, servoBucket, tServoStandard)
#pragma config(Servo, srvo_S4_C1_2, servoBlock, tServoStandard)
#pragma config(Servo, srvo_S4_C1_3, servoFlagAdjust, tServoStandard)
#pragma config(Servo, srvo_S4_C1_4, servo4, tServoNone)
#pragma config(Servo, srvo_S4_C1_5, servo5, tServoNone)
#pragma config(Servo, srvo_S4_C1_6, servo6, tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#include "JoystickDriver.c" //brings in controller functions
#include "function_library.c"
//there was a declaration of speed as 1200 if that's important.
void findIR (tSensors ir_seeker)
{
int ir_value;
nMotorEncoder[motor_right] = 0;
nMotorEncoder[motor_left] = 0;
do {
ir_value = getIRReading(ir_seeker);
if(ir_value < 6)
forward(30);
else
forward(10);
} while( getIRReading(ir_seeker) != 8 && nMotorEncoder[motor_left] < 6800 );
stops();
tossBlock();
}
task main()
{
// Initialize the robot
nMotorEncoder[motor_right] = 0;
nMotorEncoder[motor_left] = 0;
servo[servoBlock] = BLOCK_INIT;
waitForStart(); // Wait for the beginning of autonomous phase.
liftMove(50, 600);
findIR(IRSEEKER);
drive2Encoder(80, 30, BACK);
turnDeg(90, TURN_RIGHT, 100, 50);
moveDist(120, 100, 30);
turnDeg(105, TURN_LEFT, 100, 60);
moveDist(130, 100, 30);
}