From day one, I didn’t plan anything, I was talking to a friend that I wanted to build an airsoft bomb for when we do private matches for totally legit and not nerdy “Clan” called LCNI.

I purchased the Elegoo Mega 2560 from Amazon thinking that’s all I need, It wasn’t, So here’s the final list. (So far)

This list doesn’t include tools I’ve purchased like a Soldering Iron, Hot Glue Gun or an Anti-Static Mat.

Once all of my components arrived, I iniality went with something simple, just a countdown timer that would set of a buzzer, but it wasn’t enough for me, I want it to be a bit of a challenge and provide some casual stress to the match, so not only would you need to get to the bomb in the first place, you would also need to cut some wires, but cutting the wrong one could have different consequences.

For instance, let’s say if you cut the red wire, the timer would actually lose time, Blue would maybe diffuse the boom and the other colours would either cut time or make the bomb explode!

Now I know its possible and I could even get the wires to act differently each time the bomb powers on making it a challenge for me and everyone else.

My biggest issue is, I’m not great at coding, I can do HTML and CSS but Arduino is neither, so to start me off, I used a count down timer code from another Arduino enthusiast.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3f, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
#define Start 4 // start stop button
int hours = 0;
int minutes = 0;
int seconds = 0;
boolean timeState = false;
#define encoderPinA 2 // right
#define encoderPinB 3 // left
#define encoderButton 5 // switch
int HMS = 1;
int encoderPos = 0; // a counter for the dial
unsigned int lastReportedPos = 1; // change management
static boolean rotating = false; // debounce management
boolean A_set = false;
boolean B_set = false;

void setup() {

pinMode(Start, INPUT_PULLUP);
pinMode(encoderPinA, INPUT_PULLUP); //enabling pullups
pinMode(encoderPinB, INPUT_PULLUP);
pinMode(encoderButton, INPUT_PULLUP);
attachInterrupt(0, doEncoderA, CHANGE); //pin 2
attachInterrupt(1, doEncoderB, CHANGE); //pin 3
Serial.begin(9600); // output
lcd.begin(16, 2); // initialize the lcd for 16 chars 2 lines, turn on backlight
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“COUNT DOWN TIMER”);
lcd.setCursor(4, 1);
lcd.print(“00:00:00”);

}

void loop() {

if (digitalRead(encoderButton) == LOW)
{
HMS = HMS + 1;
if (HMS == 4)
{
HMS = 1;
}
delay(1000);
}
rotating = true; // reset the debouncer
encoderPos = constrain(encoderPos, -1, 1);
if (lastReportedPos != encoderPos) {

if (HMS == 1) {
hours = hours + encoderPos;
hours = constrain(hours, 0, 48);
}
else if (HMS == 2) {
minutes = minutes + encoderPos;
minutes = constrain(minutes, 0, 60);
}
else if (HMS == 3) {
seconds = seconds + encoderPos;
seconds = constrain(seconds, 0, 60);
}
// Serial.println(encoderPos); // for testing
// Serial.print(“hours “);
// Serial.println(hours);
// Serial.print(“minutes “);
// Serial.println(minutes);
// Serial.print(“seconds “);
// Serial.println(seconds);
// Serial.println(” “);
lcd.setCursor(4, 1);
if (hours <= 9)
{
lcd.print(“0”);
}
lcd.print(hours);
lcd.print(“:”);
if (minutes <= 9)
{
lcd.print(“0”);
}
lcd.print(minutes);
lcd.print(“:”);
if (seconds <= 9)
{
lcd.print(“0”);
}
lcd.print(seconds);
encoderPos = 0;
lastReportedPos = encoderPos;

}
if (digitalRead(Start) == LOW) { //start count down timer
timeState = true;
//delay(1000);
while (timeState == true) {
if (minutes == 0 && hours >= 1) {
minutes = 60;
hours = hours – 1;
}
if (seconds == 0 && minutes >= 1) {
seconds = 60;
minutes = minutes – 1;
}
else if (minutes == 0 && hours == 0 && seconds == 0) { //count down alarm
while (timeState == true) {
tone(11, 600, 250);
delay(250);
tone(11, 800, 250);
delay(250);
if (digitalRead(Start) == LOW) { // turn alarm off
timeState = false;
seconds = 1; /////////////////////////////////////////////
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“COUNT DOWN TIMER”);
lcd.setCursor(4, 1);
lcd.print(“00:00:00”);

break;
}
}
}
delay(992); // delay for keping time master setting!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
seconds = seconds – 1;
//Serial.print(“hours “); // for testing
//Serial.println(hours);
//Serial.print(“minutes “);
//Serial.println(minutes);
//Serial.print(“seconds “);
// Serial.println(seconds);
//Serial.println(” “);

lcd.setCursor(4, 1);
if (hours <= 9)
{
lcd.print(“0”);
}
lcd.print(hours);
lcd.print(“:”);
if (minutes <= 9)
{
lcd.print(“0”);
}
lcd.print(minutes);
lcd.print(“:”);
if (seconds <= 9)
{
lcd.print(“0”);
}
lcd.print(seconds);

if (digitalRead(Start) == LOW) {
delay(1000);
timeState = false;
break;
}
}
}
}

// Interrupt on A changing state
void doEncoderA() {
// debounce
if ( rotating ) delay (1); // wait a little until the bouncing is done

// Test transition, did things really change?
if ( digitalRead(encoderPinA) != A_set ) { // debounce once more
A_set = !A_set;

// adjust counter + if A leads B
if ( A_set && !B_set )
encoderPos = 1;

rotating = false; // no more debouncing until loop() hits again
}
}

// Interrupt on B changing state
void doEncoderB() {
if ( rotating ) delay (1);
if ( digitalRead(encoderPinB) != B_set ) {
B_set = !B_set;
// adjust counter – 1 if B leads A
if ( B_set && !A_set )
encoderPos = -1;

rotating = false;
}
}

The above code is from The Z-Hut now I can read and understand what all the above does and for a starting base it’s great, now my mission is to incorporate my needs into this, as of reading this, my plans have slightly changed, instead of just the Arduino Mega I’m adding 2/3 Nano’s that will talk to each other…. via Serial.

I’m surprised how easy it is to get the Arduino Nano to send data and the Arduino Mega to start a function based on a requirement, in this case when the timer has 1 minute left, now I know it’s easy to do I need to think how I can get the Arduino nano (2nd Nano) to detect a wire change.

now I know this will require an interrupt that can alter the time and I’d need something that would do a random number from 1 to maybe 8.

Elegoo Mega 2560 R3, Used as master

Now the plan of action, I’ll be using the following list of items as some items in the Elegoo Mega Kit aren’t the best of quality, despite it still being a great price.

Right, now I’m pretty sure this is all I need, well apart from the case that will hold all the components, I’ll release the full specs once I finished the bomb!

Leave a Reply