Arduino Sink Starter Averager

files.catbox.moe/eq7k84.mp4

Arduino Nano
Elegoo Obstacle Detector
MG995S Servos (x2)
9G Servos (x2)
1000 uf Capacitor
Photoresistor
330 ohm Resistor
1K ohm Resistor
5V Power Supply




  1. // sink starter
  2. // vgmlr
  3. // updated with button restore
  4. #include "FastLED.h"
  5. #define NUM_LEDS 30
  6. #define LED_TYPE WS2812B
  7. #define COLOR_ORDER GRB
  8. CRGB leds[NUM_LEDS];
  9. #define PIN 16
  10. int data = 255;
  11. int r = 0;
  12. int g = 0;
  13. int b = 255;
  14. int j = 0;
  15. int k = 0;
  16. #include "VarSpeedServo.h"
  17. VarSpeedServo left;
  18. VarSpeedServo l_lift;
  19. VarSpeedServo right;
  20. VarSpeedServo r_lift;
  21. const int left_pin = 3;
  22. const int l_lift_pin = 5;
  23. const int right_pin = 7;
  24. const int r_lift_pin = 9;
  25. const int rldown = 100;
  26. const int lldown = 80;
  27. const int rlup = 6;
  28. const int llup = 180;
  29. const int lup = 10;
  30. const int rup = 170;
  31. const int ldown_second = 92;
  32. const int rdown_second = 100;
  33. const int button = 18;
  34. const int motion = 11;
  35. int ismoved;
  36. void setup() {
  37. pinMode(motion, INPUT);
  38. pinMode(button, INPUT);
  39. FastLED.addLeds< LED_TYPE, PIN, COLOR_ORDER >(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  40. // wait for user activation
  41. // power outage safety
  42. while (digitalRead(button) == LOW) {
  43. neoshow(255, 0, 0, 150);
  44. delay(500);
  45. neoshow(0, 0, 0, 150);
  46. delay(500);
  47. }
  48. l_lift.attach(l_lift_pin);
  49. r_lift.attach(r_lift_pin);
  50. delay(1000); // default error fix
  51. right.attach(right_pin);
  52. left.attach(left_pin);
  53. delay(500);
  54. l_lift.write(lldown, 255, false);
  55. r_lift.write(rldown, 255, true);
  56. delay(1000);
  57. left.write(lup, 100, false);
  58. right.write(rup, 100, true);
  59. delay(1000);
  60. l_lift.write(llup, 180, false);
  61. r_lift.write(rlup, 180, true);
  62. delay(500);
  63. l_lift.detach();
  64. r_lift.detach();
  65. left.detach();
  66. right.detach();
  67. colorWipe(0x00, 0x00, 0xff, 50);
  68. neoshow(0, 0, 255, 220);
  69. }
  70. void loop() {
  71. // if motion
  72. ismoved = digitalRead(motion);
  73. if (ismoved == LOW) {
  74. doit();
  75. } else {
  76. delay(10);
  77. }
  78. }
  79. void doit() {
  80. // reconnect pins
  81. l_lift.attach(l_lift_pin);
  82. r_lift.attach(r_lift_pin);
  83. right.attach(right_pin);
  84. left.attach(left_pin);
  85. // give it a chance
  86. delay(100);
  87. // lift down first
  88. l_lift.write(lldown, 255, false);
  89. r_lift.write(rldown, 255, true);
  90. delay(500);
  91. // push
  92. left.write(ldown_second, 200, false);
  93. right.write(rdown_second, 200, true);
  94. delay(500);
  95. // return
  96. left.write(lup, 200, false);
  97. right.write(rup, 200, true);
  98. delay(500);
  99. // lift
  100. l_lift.write(llup, 100, false);
  101. r_lift.write(rlup, 100, true);
  102. delay(500);
  103. // disconnect pins
  104. l_lift.detach();
  105. r_lift.detach();
  106. left.detach();
  107. right.detach();
  108. // pavlov
  109. lightshow();
  110. }
  111. void lightshow() {
  112. j = random(1, 3);
  113. if (j == 1) {
  114. for (k = 0; k < 10; k++) {
  115. TwinkleRandom(20, 100, false);
  116. }
  117. } else if (j == 2) {
  118. for (k = 0; k < 2; k++) {
  119. rainbowCycle(20);
  120. }
  121. } else if (j == 3) {
  122. for (k = 0; k < 3; k++) {
  123. colorWipe(random(255), random(255), random(255), 50);
  124. colorWipe(0, 0, 0, 50);
  125. }
  126. }
  127. neoshow(random(255), random(255), random(255), 220);
  128. }
  129. void neoshow(int r, int g, int b, int brightness) {
  130. Serial.println(r);
  131. Serial.println(g);
  132. Serial.println(b);
  133. FastLED.setBrightness(brightness);
  134. for (int i = 0; i < NUM_LEDS; i++ )
  135. {
  136. leds[i] = CRGB(r, g, b);
  137. }
  138. FastLED.show();
  139. }
  140. void showStrip() {
  141. #ifdef ADAFRUIT_NEOPIXEL_H
  142. // NeoPixel
  143. strip.show();
  144. #endif
  145. #ifndef ADAFRUIT_NEOPIXEL_H
  146. // FastLED
  147. FastLED.show();
  148. #endif
  149. }
  150. void setPixel(int Pixel, byte red, byte green, byte blue) {
  151. #ifdef ADAFRUIT_NEOPIXEL_H
  152. // NeoPixel
  153. strip.setPixelColor(Pixel, strip.Color(red, green, blue));
  154. #endif
  155. #ifndef ADAFRUIT_NEOPIXEL_H
  156. // FastLED
  157. leds[Pixel].r = red;
  158. leds[Pixel].g = green;
  159. leds[Pixel].b = blue;
  160. #endif
  161. }
  162. void setAll(byte red, byte green, byte blue) {
  163. for (int i = 0; i < NUM_LEDS; i++ ) {
  164. setPixel(i, red, green, blue);
  165. }
  166. showStrip();
  167. }
  168. void rainbowCycle(int SpeedDelay) {
  169. byte *c;
  170. uint16_t i, j;
  171. for (j = 0; j < 256 * 5; j++) { // 5 cycles of all colors on wheel
  172. for (i = 0; i < NUM_LEDS; i++) {
  173. c = Wheel(((i * 256 / NUM_LEDS) + j) & 255);
  174. setPixel(i, *c, *(c + 1), *(c + 2));
  175. }
  176. showStrip();
  177. delay(SpeedDelay);
  178. }
  179. }
  180. byte * Wheel(byte WheelPos) {
  181. static byte c[3];
  182. if (WheelPos < 85) {
  183. c[0] = WheelPos * 3;
  184. c[1] = 255 - WheelPos * 3;
  185. c[2] = 0;
  186. } else if (WheelPos < 170) {
  187. WheelPos -= 85;
  188. c[0] = 255 - WheelPos * 3;
  189. c[1] = 0;
  190. c[2] = WheelPos * 3;
  191. } else {
  192. WheelPos -= 170;
  193. c[0] = 0;
  194. c[1] = WheelPos * 3;
  195. c[2] = 255 - WheelPos * 3;
  196. }
  197. return c;
  198. }
  199. void TwinkleRandom(int Count, int SpeedDelay, boolean OnlyOne) {
  200. setAll(0, 0, 0);
  201. for (int i = 0; i < Count; i++) {
  202. setPixel(random(NUM_LEDS), random(0, 255), random(0, 255), random(0, 255));
  203. showStrip();
  204. delay(SpeedDelay);
  205. if (OnlyOne) {
  206. setAll(0, 0, 0);
  207. }
  208. }
  209. delay(SpeedDelay);
  210. }
  211. void colorWipe(byte red, byte green, byte blue, int SpeedDelay) {
  212. for (uint16_t i = 0; i < NUM_LEDS; i++) {
  213. setPixel(i, red, green, blue);
  214. showStrip();
  215. delay(SpeedDelay);
  216. }
  217. }
Update(s)-
1. ptmr | 343025 [Changelog]
10:22 343 025
Dev-
1. TVShow (227) 'CSA'
2. Wedge (Miter) 1.0.0
3. TVShow (228) 'APT'
4. TVProgram (83) 'BXT'
11:51 339 025

Menu
Index
Engineering
Entertainment
Literature
Miscellaneous
Contact
Search
tiktok.com/@vgmlr
youtube.com/@vgmlr
Miter
@vgmlr
=SUM(parts)
86 miters
131 tenons
Subscribe
0.0009