-
Notifications
You must be signed in to change notification settings - Fork 0
/
NXTServoTest.c
77 lines (54 loc) · 1.96 KB
/
NXTServoTest.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#pragma config(Hubs, S1, HTMotor, HTMotor, HTServo, none)
#pragma config(Sensor, S2, ElevatorTopStop, sensorTouch)
#pragma config(Sensor, S3, SMUX2, sensorI2CCustom)
#pragma config(Sensor, S4, SMUX1, sensorI2CCustom)
#pragma config(Motor, motorA, IndicatorLight, tmotorNormal, openLoop)
#pragma config(Motor, motorB, , tmotorNormal, PIDControl)
#pragma config(Motor, motorC, , tmotorNormal, PIDControl)
#pragma config(Motor, mtr_S1_C1_1, motorD, tmotorNormal, openLoop)
#pragma config(Motor, mtr_S1_C1_2, motorE, tmotorNormal, openLoop)
#pragma config(Motor, mtr_S1_C2_1, motorF, tmotorNormal, openLoop)
#pragma config(Motor, mtr_S1_C2_2, motorG, tmotorNormal, openLoop)
#pragma config(Servo, srvo_S1_C3_5, Servo, tServoStandard)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
//#include "joystickDriver.c"
#define kPositionIncrement 1
task main()
{
//waitForStart(); // wait for start of tele-op phase
short position = 255 / 2;
long lastUpdate;
long updateInterval = 30;
//Controller controller;
while (true)
{
//UpdatePrimaryController(controller);
/*
if ( ControllerButtonIsPressed(controller, ControllerButton4) )
{
updateInterval = 130;
}
else if ( ControllerButtonIsPressed(controller, ControllerButton2) )
{
updateInterval = 25;
}
*/
if ( nPgmTime > (lastUpdate + updateInterval) )
{
if ( nNxtButtonPressed == kRightButton )
{
position += kPositionIncrement;
lastUpdate = nPgmTime;
}
else if ( nNxtButtonPressed == kLeftButton )
{
position -= kPositionIncrement;
lastUpdate = nPgmTime;
}
if ( position > 255 ) position = 255;
if ( position < 0 ) position = 0;
}
servo[Servo] = position;
nxtDisplayCenteredTextLine(2, (string)position);
}
}