-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rhett'sCode.c
129 lines (119 loc) · 4.39 KB
/
Rhett'sCode.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#pragma config(Sensor, in1, pot, sensorPotentiometer)
#pragma config(Motor, port2, RightMotor, tmotorServoStandard, openLoop)
#pragma config(Motor, port3, LeftMotor, tmotorVex393_MC29, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
bool boolSlowButton = false;
//Play the digdug theme :)
task digdug()
{
while(1)
{
// 225 = Tempo
// 5 = Default octave
// Quarter = Default note length
// 10% = Break between notes
//
playTone( 523, 12); wait1Msec( 133); // Note(C, Duration(Eighth))
playTone( 783, 12); wait1Msec( 133); // Note(G, Duration(Eighth))
playTone( 523, 12); wait1Msec( 133); // Note(C, Duration(Eighth))
playTone( 783, 12); wait1Msec( 133); // Note(G, Duration(Eighth))
playTone( 493, 12); wait1Msec( 133); // Note(B4, Duration(Eighth))
playTone( 783, 12); wait1Msec( 133); // Note(G, Duration(Eighth))
playTone( 493, 12); wait1Msec( 133); // Note(B4, Duration(Eighth))
playTone( 783, 12); wait1Msec( 133); // Note(G, Duration(Eighth))
playTone( 466, 12); wait1Msec( 133); // Note(A#4, Duration(Eighth))
playTone( 783, 12); wait1Msec( 133); // Note(G, Duration(Eighth))
playTone( 466, 12); wait1Msec( 133); // Note(A#4, Duration(Eighth))
playTone( 783, 12); wait1Msec( 133); // Note(G, Duration(Eighth))
playTone( 440, 12); wait1Msec( 133); // Note(A4, Duration(Eighth))
playTone( 783, 12); wait1Msec( 133); // Note(G, Duration(Eighth))
playTone( 440, 12); wait1Msec( 133); // Note(A4, Duration(Eighth))
playTone( 783, 12); wait1Msec( 133); // Note(G, Duration(Eighth))
playTone( 415, 12); wait1Msec( 133); // Note(G#4, Duration(Eighth))
playTone( 698, 12); wait1Msec( 133); // Note(F, Duration(Eighth))
playTone( 415, 12); wait1Msec( 133); // Note(G#4, Duration(Eighth))
playTone( 698, 12); wait1Msec( 133); // Note(F, Duration(Eighth))
playTone( 415, 12); wait1Msec( 133); // Note(G#4, Duration(Eighth))
playTone( 698, 12); wait1Msec( 133); // Note(F, Duration(Eighth))
playTone( 415, 12); wait1Msec( 133); // Note(G#4, Duration(Eighth))
playTone( 698, 12); wait1Msec( 133); // Note(F, Duration(Eighth))
playTone( 391, 12); wait1Msec( 133); // Note(G4, Duration(Eighth))
playTone( 698, 12); wait1Msec( 133); // Note(F, Duration(Eighth))
playTone( 391, 12); wait1Msec( 133); // Note(G4, Duration(Eighth))
playTone( 698, 12); wait1Msec( 133); // Note(F, Duration(Eighth))
playTone( 440, 12); wait1Msec( 133); // Note(A4, Duration(Eighth))
playTone( 698, 12); wait1Msec( 133); // Note(F, Duration(Eighth))
playTone( 493, 12); wait1Msec( 133); // Note(B4, Duration(Eighth))
}
}
//Slow down the controls if a button is pressed
void SlowButton()
{
if(vexRT(Btn8D) == true)
{
boolSlowButton = true;
}
if(vexRT(Btn8U) == true)
{
boolSlowButton = false;
}
}
//this code is also called tank drive. One joystick controls 1 side of the robot base.
void StandardDrive()
{
if(boolSlowButton == true)
{
motor[RightMotor] = vexRT(Ch2)/3;
motor[LeftMotor] = vexRT(Ch3)/3;
}
else
{
motor[RightMotor] = vexRT(Ch2);
motor[LeftMotor] = vexRT(Ch3);
}
}
//we dont need this code, but ill keep it here so if it's needed its here :)
// This code has 1 stick for up and down, as well as turning.
/*void ArcadeDrive1Stick()
{
motor[LeftMotor] = (vexRT[Ch2] + vexRT[Ch1])/2; // (y + x)/2
motor[RightMotor] = (vexRT[Ch2] - vexRT[Ch1])/2; // (y - x)/2
}
*/
// This code has 1 stick for up and down, and the other for turning.
void ArcadeDrive2Stick()
{
if(boolSlowButton == true)
{
motor[LeftMotor] = (vexRT[Ch3] + vexRT[Ch1])/3; // (y + x)/3
motor[RightMotor] = (vexRT[Ch3] - vexRT[Ch1])/3; // (y - x)/3
}
else
{
motor[LeftMotor] = (vexRT[Ch3] + vexRT[Ch1]); // (y + x)
motor[RightMotor] = (vexRT[Ch3] - vexRT[Ch1]); // (y - x)
}
}
// if pot < 2047, run arcade controls, else run standard drive (tank controls)
void Base()
{
if(SensorValue[pot] < 2047)
{
ArcadeDrive2Stick();
}
else
{
StandardDrive();
}
}
//instructions: if the potentiometer is less than halfway, use arcade drive. If it's over halfway, use tank drive.
task main()
{
startTask(digdug);
bool boolReitzigSanity = false; //this is always false, as Mr. Reitzig is insane :p
while(boolReitzigSanity == false) // run forever
{
SlowButton();
Base();
}
}