Menu
Index
Engineering
Entertainment
Literature
Miscellaneous
Contact
Search
tiktok.com/@pkvi.xyz
scored.co/u/pkvi_mv
Why Ayh?
Miter
Miter
@pkvi
"...may not meet professional standards."
1767 miters
123 tenons
Subscribe
0.0175
Arduino Licorice Launcher






  1. // Arduino Licorice Launcher
  2. // pkvi
  3. // RF Tracking @ Warner K. robowarner.com
  4. #include "EEPROM.h"
  5. #include "Servo.h"
  6. // Centering
  7. // Too small adjusts too frequently
  8. // Too large will pass over signal
  9. #define buffering 26
  10. // Output Pin
  11. #define ANT_WAVEFORM_OUT 8
  12. // Input Pin
  13. #define SPEAKER_FROM_WALKIETALKIE A1
  14. // Calibration Pin
  15. #define CALIBRATE_IN 11
  16. // Variables
  17. uint16_t caliset = 0;
  18. uint16_t voltage = 0;
  19. int state = 1;
  20. // Servo Assignment
  21. Servo turn;
  22. int turnpin = 6;
  23. Servo loader;
  24. int loaderpin = 9;
  25. Servo fire;
  26. int firepin = 10;
  27. Servo arm;
  28. int arm = 11;
  29. // LED Pins
  30. int red = 3;
  31. int blue = 4;
  32. void setup() {
  33. analogReference(DEFAULT);
  34. turn.attach(turnpin);
  35. loader.attach(loaderpin);
  36. fire.attach(firepin);
  37. arm.attach(armpin);
  38. pinMode(red, OUTPUT);
  39. pinMode(blue, OUTPUT);
  40. digitalWrite(red, LOW);
  41. digitalWrite(blue, LOW);
  42. Serial.begin(9600);
  43. delay(6000); // Allow Power Up
  44. pinMode(ANT_WAVEFORM_OUT, OUTPUT);
  45. pinMode(SPEAKER_FROM_WALKIETALKIE, INPUT);
  46. pinMode(CALIBRATE_IN, INPUT);
  47. digitalWrite(CALIBRATE_IN, HIGH);
  48. // Read EEPROM
  49. byte HByte = EEPROM.read(1);
  50. byte LByte = EEPROM.read(2);
  51. caliset = word(HByte, LByte);
  52. Serial.print("EEPROM Calibration number: ");
  53. Serial.println(caliset);
  54. // Calibration Check and Delay
  55. // Aim Receiver and Clear Area
  56. if (digitalRead(CALIBRATE_IN) == LOW) {
  57. delay(10000);
  58. }
  59. }
  60. void loop() {
  61. if (state == 1) {
  62. // Engage Licorice Weapon
  63. digitalWrite(red, HIGH);
  64. // Trigger Position Open
  65. fire.write(45);
  66. delay(1000);
  67. // Arm Launcher
  68. arm.write(180);
  69. delay(1500);
  70. // Lock Trigger
  71. fire.write(90);
  72. // Load Launcher
  73. loader.write(180);
  74. delay(330);
  75. // Stall Position
  76. loader.write(88);
  77. // Remove Arm
  78. arm.write(40);
  79. // Licorice Launcher is Hot
  80. digitalWrite(red, LOW);
  81. digitalWrite(blue, HIGH);
  82. state = 2;
  83. } else {
  84. // Hold for Command from JACOB
  85. if (Serial.available()) {
  86. char ser = Serial.read();
  87. switch (ser) {
  88. case 'L':
  89. load();
  90. break;
  91. case 'F':
  92. fire();
  93. break;
  94. }
  95. }
  96. }
  97. }
  98. void load() {
  99. // Load Launcher
  100. loader.write(180);
  101. delay(330);
  102. loader.write(88);
  103. }
  104. void fire() {
  105. // Antenna Switching Waveform
  106. digitalWrite(ANT_WAVEFORM_OUT, HIGH);
  107. delay(1);
  108. digitalWrite(ANT_WAVEFORM_OUT, LOW);
  109. delay(1);
  110. digitalWrite(ANT_WAVEFORM_OUT, HIGH);
  111. delay(1);
  112. digitalWrite(ANT_WAVEFORM_OUT, LOW);
  113. delay(1);
  114. digitalWrite(ANT_WAVEFORM_OUT, HIGH);
  115. delay(1);
  116. digitalWrite(ANT_WAVEFORM_OUT, LOW);
  117. delay(1);
  118. digitalWrite(ANT_WAVEFORM_OUT, HIGH);
  119. delay(1);
  120. digitalWrite(ANT_WAVEFORM_OUT, LOW);
  121. delay(1);
  122. // Read Speaker Voltage
  123. voltage = analogRead(SPEAKER_FROM_WALKIETALKIE);
  124. // If in Calibration Mode
  125. // Store to EEPROM
  126. if (digitalRead(CALIBRATE_IN) == LOW) {
  127. caliset = voltage;
  128. byte HByte = highByte(caliset);
  129. byte LByte = lowByte(caliset);
  130. EEPROM.write(1, HByte);
  131. EEPROM.write(2, LByte);
  132. delay(5000);
  133. endprogram();
  134. }
  135. // Stall Turning
  136. if (voltage > (caliset - buffering) && voltage < (caliset + buffering)) {
  137. // Fire
  138. launch();
  139. }
  140. // Turn Left
  141. if (voltage > (caliset + buffering)) {
  142. turn.write(180);
  143. delay(15);
  144. Serial.print("In, Cal\t");
  145. Serial.print(voltage);
  146. Serial.print("\t");
  147. Serial.println(caliset);
  148. // Return Cycle
  149. fire();
  150. }
  151. // Turn Right
  152. if (voltage < (caliset - buffering)) {
  153. turn.write(0);
  154. delay(15);
  155. Serial.print("In, Cal\t");
  156. Serial.print(voltage);
  157. Serial.print("\t");
  158. Serial.println(caliset);
  159. // Return Cycle
  160. fire();
  161. }
  162. delay(5);
  163. Serial.print("In, Cal\t");
  164. Serial.print(voltage);
  165. Serial.print("\t");
  166. Serial.println(caliset);
  167. }
  168. void launch() {
  169. // Release Trigger
  170. fire.write(45);
  171. delay(1000);
  172. // Reset
  173. state = 1;
  174. break;
  175. }
  176. void endprogram() {
  177. Serial.print("Calibrated to: ");
  178. Serial.print(caliset);
  179. loopy:
  180. goto loopy;
  181. }