/*
###### Airsoft/Paintball Domination Game ######
Description:
No space for the batteries, so that was a bad design. Everything but the 6 LED lamps is powered
by a 5v USB battery bank. The LED lamps are powered by an airsoft 11.1v lipo.
To start a game, just press and release the "admin" button (the yellow/orange middle one that
doesn't illuminate. That immediately begins starts the game timer (which can be changed in the code).
The box blinks orange to indicate no team has held the point yet.
Blue team presses and releases the blue button and their time begins immediately, complete
with the blue flashing light. Green button does the same.
When the game timer runs out, the program looks at the two accrued times, and whichever
team has the most time, the box will rapidly blink that team's color LED lamps.
In the case of a tie, the box will rapidly blink the orange admin lights. And, of course,
The circuit:
Arduino Uno R3.
SunFounder IIC I2C 16x2.
3 momentary push buttons (two illuminate).
Three relays.
Six LED lamps in appropriate colors.
Translucent ammo can.
Created 21 September 2023
Modified 6 October 2023
* added "Press Start"
* LCD now shows HH:MM:SS
By BearsoftME
for Southern Aroostook Action Sports
SAASMaine.com
Any questions or comments, please email the author: [email protected]
Demo: https://www.youtube.com/watch?v=ft3u3nQDFkM
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // Initialize the LCD
/* Keypad setup */
const byte KEYPAD_ROWS = 4;
const byte KEYPAD_COLS = 4;
byte rowPins[KEYPAD_ROWS] = {11, 10, 9, 8};
byte colPins[KEYPAD_COLS] = {A0, A1, A2, A4};
char keys[KEYPAD_ROWS][KEYPAD_COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, KEYPAD_ROWS, KEYPAD_COLS);
uint64_t value = 0;
void showSpalshScreen() {
lcd.print("GoodArduinoCode");
lcd.setCursor(3, 1);
String message = "Calculator";
for (byte i = 0; i < message.length(); i++) {
lcd.print(message[i]);
delay(50);
}
delay(500);
}
void updateCursor() {
if (millis() / 250 % 2 == 0 ) {
lcd.cursor();
} else {
lcd.noCursor();
}
}
const int orangeButtonPin = 2; // Orange button pin
const int blueButtonPin = 3; // Blue team button pin
const int greenButtonPin = 4; // Green team button pin
const int orangeRelayPin = 5; // Orange relay pin
const int blueRelayPin = 6; // Blue team relay pin
const int greenRelayPin = 7; // Green team relay pin
unsigned long gameStartTime = 0;
unsigned long blueStartTime = 0;
unsigned long greenStartTime = 0;
unsigned long blueElapsedTime = 0;
unsigned long greenElapsedTime = 0;
unsigned long blueTime = 0;
unsigned long greenTime = 0;
unsigned long bluePausedTime = 0;
unsigned long greenPausedTime = 0;
const unsigned long gameDuration = 60 * 1000; // in millieconds
bool gameTimerRunning = false;
bool blueTimerRunning = false;
bool greenTimerRunning = false;
bool blueButtonStatePrev = false;
bool greenButtonStatePrev = false;