Arduino Umpire Mask


  1. // Arduino Umpire Mask
  2. // pkvi
  3. #include "Adafruit_NeoPixel.h"
  4. // Neopixel Data Pins
  5. #define PINSTRIP 3
  6. #define PINPIXEL 4
  7. // LED Count and Setup
  8. Adafruit_NeoPixel strip = Adafruit_NeoPixel(15,
  9. PINSTRIP, NEO_GRB + NEO_KHZ800);
  10. Adafruit_NeoPixel pixels = Adafruit_NeoPixel(6,
  11. PINPIXEL, NEO_GRB + NEO_KHZ800);
  12. // Strike Count
  13. int strikes = 0;
  14. // Ball Count
  15. int balls = 0;
  16. // Bluetooth Data
  17. char call = 0;
  18. void setup() {
  19. Serial.begin(9600);
  20. strip.begin();
  21. strip.show();
  22. pixels.begin();
  23. colorWipe(strip.Color(255, 0, 0), 50);
  24. }
  25. void loop() {
  26. // Clear Strip
  27. colorWipe(strip.Color(0, 0, 0), 50);
  28. if (Serial.available() > 0) {
  29. call = Serial.read();
  30. if (call == '1') {
  31. colorWipe(strip.Color(255, 0, 0), 50);
  32. strike();
  33. delay(1000);
  34. }
  35. else if (call == '2') {
  36. colorWipe(strip.Color(0, 255, 0), 50);
  37. ball();
  38. delay(1000);
  39. }
  40. else if (call == '3') {
  41. reload();
  42. }
  43. }
  44. }
  45. void strike() {
  46. if (strikes == 0) {
  47. // Red Strike Count
  48. pixels.setPixelColor(5, pixels.Color(255, 0, 0));
  49. strikes = 1;
  50. }
  51. else if (strikes == 1) {
  52. pixels.setPixelColor(4, pixels.Color(255, 0, 0));
  53. }
  54. pixels.show();
  55. }
  56. void ball() {
  57. if (balls == 0) {
  58. // Green Ball
  59. pixels.setPixelColor(0, pixels.Color(0, 255, 0));
  60. balls = 1;
  61. }
  62. else if (balls == 1) {
  63. pixels.setPixelColor(1, pixels.Color(0, 255, 0));
  64. balls = 2;
  65. }
  66. else if (balls == 2) {
  67. pixels.setPixelColor(2, pixels.Color(0, 255, 0));
  68. }
  69. pixels.show();
  70. }
  71. void reload() {
  72. colorWipe(strip.Color(255, 0, 0), 50);
  73. pixels.setPixelColor(0, pixels.Color(0, 0, 0));
  74. pixels.setPixelColor(1, pixels.Color(0, 0, 0));
  75. pixels.setPixelColor(2, pixels.Color(0, 0, 0));
  76. pixels.setPixelColor(4, pixels.Color(0, 0, 0));
  77. pixels.setPixelColor(5, pixels.Color(0, 0, 0));
  78. strikes = 0;
  79. balls = 0;
  80. pixels.show();
  81. }
  82. void colorWipe(uint32_t c, uint8_t wait) {
  83. for (uint16_t i = 0; i < strip.numPixels(); i++) {
  84. strip.setPixelColor(i, c);
  85. strip.show();
  86. delay(wait);
  87. }
  88. }

Menu
Index
Engineering
Entertainment
Literature
Miscellaneous
Contact
Search
tiktok.com/@pkvi.xyz
Why Ayh?
Miter
Miter
@pkvi
"...may not meet professional standards."
2,364 miters
123 tenons
Subscribe
0.00494