This repository has been archived by the owner on Oct 13, 2018. It is now read-only.
forked from JasperNelson/ESHS_VEX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVariable Motor Test Bench
86 lines (49 loc) · 2.42 KB
/
Variable Motor Test Bench
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
78
79
80
81
82
83
84
85
86
/* this update finally fixes the problem with the motor continuing to run after the sonar is regestering a value greater than 20 */
#pragma config(Sensor, in1, Potentiometer, sensorPotentiometer)
#pragma config(Sensor, in2, Light_sensor, sensorReflection)
#pragma config(Sensor, in3, Line_follower, sensorLineFollower)
#pragma config(Sensor, dgtl1, bump, sensorTouch)
#pragma config(Sensor, dgtl2, Limit, sensorTouch)
#pragma config(Sensor, dgtl3, Sonar_in, sensorSONAR_cm)
#pragma config(Sensor, dgtl5, Quad_in, sensorQuadEncoder)
#pragma config(Sensor, dgtl11, Bump_, sensorTouch)
#pragma config(Motor, port2, right_motor, tmotorVex269_MC29, openLoop)
#pragma config(Motor, port3, Servo, tmotorServoStandard, openLoop)
#pragma config(Motor, port9, left_motor, tmotorVex269_MC29, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main()
{
// This code is for a VEX POE test bench with the ability to control the speed of rotation of the motors using a multitude of different methods.
int x; //
int light; //
int distance; //
int degrees; // Number of degrees the potentiometer rotates
SensorValue[Quad_in] = 0;
SensorValue[Potentiometer] = 0; // Resets the potentiometer before the robot starts
while (1 == 1){
if(SensorValue(bump) == 1) {
x = SensorValue[Quad_in] / 2; // Changes the value x to be equal to the value the quadrature encoder records
motor[right_motor] = x;
motor[left_motor] = x;
}
if(SensorValue[Sonar_in] < 10) { // If the sensor value is greater than ~20 inches then the sonar will be be turned off
distance = SensorValue[Sonar_in] * 5;
motor[right_motor] = distance;
motor[left_motor] = distance;
}
if(SensorValue(Bump_) == 1) {
light = SensorValue[Light_sensor] / -2;
motor[Servo] = light; // Note: be weary about how much you move this, too much movement could destroy your servo; run this at your own risk!
}
if(SensorValue(Potentiometer) > 10) {
degrees = SensorValue[Potentiometer] / 5; //Note: be weary about how much you move the potentiometer, too much movement could destroy your servo run this at your own risk!
motor[Servo] = degrees;
}
if (SensorValue[Sonar_in] >= 20 ) {
motor[right_motor] = 0;
motor[left_motor] = 0;
motor[Servo] = 0;
SensorValue[Potentiometer] = 0;
}
}
}