Pith - arduino_umpire_mask
arduino_umpire_mask/arduino_umpire_mask.ino [2.0 kb]
Modified: 00:32:52 57 026 (15 May 026)
16 Days Ago
// Arduino Umpire Mask
// vgmlr
#include "Adafruit_NeoPixel.h"
// Neopixel Data Pins
#define PINSTRIP 3
#define PINPIXEL 4
// LED Count and Setup
Adafruit_NeoPixel strip = Adafruit_NeoPixel(15, 
PINSTRIP, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(6, 
PINPIXEL, NEO_GRB + NEO_KHZ800);
// Strike Count
int strikes = 0;
// Ball Count
int balls = 0;
// Bluetooth Data
char call = 0;
void setup() {
  Serial.begin(9600);
  strip.begin();
  strip.show();
  pixels.begin();
  colorWipe(strip.Color(255, 0, 0), 50);
}
void loop() {
  // Clear Strip
  colorWipe(strip.Color(0, 0, 0), 50);
  if (Serial.available() > 0) {
    call = Serial.read();
    if (call == '1') {
      colorWipe(strip.Color(255, 0, 0), 50);
      strike();
      delay(1000);
    }
    else if (call == '2') {
      colorWipe(strip.Color(0, 255, 0), 50);
      ball();
      delay(1000);
    }
    else if (call == '3') {
      reload();
    }
  }
}
void strike() {
  if (strikes == 0) {
    // Red Strike Count
    pixels.setPixelColor(5, pixels.Color(255, 0, 0));
    strikes = 1;
  }
  else if (strikes == 1) {
    pixels.setPixelColor(4, pixels.Color(255, 0, 0));
  }
  pixels.show();
}
void ball() {
  if (balls == 0) {
    // Green Ball
    pixels.setPixelColor(0, pixels.Color(0, 255, 0));
    balls = 1;
  }
  else if (balls == 1) {
    pixels.setPixelColor(1, pixels.Color(0, 255, 0));
    balls = 2;
  }
  else if (balls == 2) {
    pixels.setPixelColor(2, pixels.Color(0, 255, 0));
  }
  pixels.show();
}
void reload() {
  colorWipe(strip.Color(255, 0, 0), 50);
  pixels.setPixelColor(0, pixels.Color(0, 0, 0));
  pixels.setPixelColor(1, pixels.Color(0, 0, 0));
  pixels.setPixelColor(2, pixels.Color(0, 0, 0));
  pixels.setPixelColor(4, pixels.Color(0, 0, 0));
  pixels.setPixelColor(5, pixels.Color(0, 0, 0));
  strikes = 0;
  balls = 0;
  pixels.show();
}
void colorWipe(uint32_t c, uint8_t wait) {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
  }
}
Updates
Shim - Android 70.026.1
Wedge - Linux 68.026.1
Wedge - Android 68.026.1
Taper - Linux 64.026.1
Ayh Extension - Chrome 63.026.1
Dev
TVShow (227) 'CSA'
TVShow (228) 'APT'
TVProgram (83) 'BXT'
Miter Update(s)
Shim (Dictation)

Menu
Calendar
Project Tin (024/029)
Miter
RSS Feed
User Avatar
@vgmlr
=SUM(parts)