-
Notifications
You must be signed in to change notification settings - Fork 1
/
Board RC Controls.c
73 lines (62 loc) · 1.63 KB
/
Board RC Controls.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
#pragma config(Motor, port1, leftWheel, tmotorVex393_HBridge, openLoop)
#pragma config(Motor, port2, rightWheel, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port3, armLeftFront, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port4, armLeftBack, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port5, armRightFront, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port6, armRightBack, tmotorVex393_MC29, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main()
{
int leftSpeed;
int rightSpeed;
int armSpeed;
while (true)
{
//To control the left side using channel 3
if (vexRT[Ch3] > -35 && vexRT[Ch3] < 35)
{
leftSpeed = 0;
}
else
{
leftSpeed = vexRT[Ch3];
}
//To control the right side using channel 2
if (vexRT[Ch2] > -35 && vexRT[Ch2] < 35)
{
rightSpeed = 0;
}
else
{
rightSpeed = vexRT[Ch2];
}
motor[leftWheel] = leftSpeed;
motor[rightWheel] = -rightSpeed;
//lift up using Button 5U or 6D
if (vexRT[Btn5U] == 1 || vexRT[Btn6D] == 1) //moving arm up
{
armSpeed = 127;
}
else
{
armSpeed = 0;
}
motor[armLeftFront] = armSpeed;
motor[armLeftBack] = armSpeed;
motor[armRightFront] = -armSpeed;
motor[armRightBack] = -armSpeed;
//lift up using Button 5D or 6U
if (vexRT[Btn5D] == 1 || vexRT[Btn6U] == 1) //moving arm down
{
armSpeed = -127;
}
else
{
armSpeed = 0;
}
motor[armLeftFront] = armSpeed;
motor[armLeftBack] = armSpeed;
motor[armRightFront] = -armSpeed;
motor[armRightBack] = -armSpeed;
}
}