Project showcase
Prop Bomb For Paintball/Airsoft

Prop Bomb For Paintball/Airsoft © GPL3+

The objective: a prop "bomb" for paintball/airsoft.

  • 3,920 views
  • 3 comments
  • 11 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)

About this project

This is the final version of the prop bomb I have created for use in paintball. It features a 10-digit matrix keypad, an Arduino UNO, a 16x2 LCD screen, a few LEDs and a buzzer. Turn the prop on and it checks the power after the voltage regulator.

Then it goes to the start of the game. User enters a 4-digit disarming code and enters a timer in HH:MM:SS format, then presses "#" to arm it (start the countdown). To disarm, the user must press "*" then enter the 4-digit password.

  • If the code is entered wrong once, the time will cut in half.
  • If the code is entered wrong twice, the time cuts in half again and speeds up.
  • If the time is entered wrong a third time, the bomb will "explode".

Code

bomb_project.inoC/C++
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Prop bomb for paintball/airsoft objective game, bomb uses a 12 armcode keypad, a LCD screen, 3 LED's and a speaker.
// Code reads chip input voltage (after the regulator) and if voltage is above minimum required to run it starts the bomb code.
// If voltage is low it will tell you to replace the battery and stays on that screen.
// User sets the disarm code (4 digits).
// Then user sets timer ( HH:MM:SS )
// You have 3 tries to get the code entered coorectly, 1st wrong attempt cuts the time in half,
// 2nd wrong attempt cuts time in half again and speeds time up by a multiple 10,
// The 3rd wrong attempt detonates the bomb.
// Must press * to enter the disarm code.
// If you mess up entering your disarm code press "#" to reset your try.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <Keypad.h>
#include <LiquidCrystal.h>

int Hours = 00;
int Minutes = 00;
int Seconds = 00;
int trycount = 0;
int keycount = 0;
int i = 0;

int redled = A4;
int yellowled = A5;
int greenled = A3;

int hourstenscode;
int hoursonescode;
int mintenscode;
int minonescode;
int sectenscode;
int seconescode;

long secMillis = 0;
long interval = 1000;

char password[4];
char entered[4];

int readVcc() {
  // Read 1.1V reference against AVcc
  // set the reference to Vcc and the measurement to the internal 1.1V reference
#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
  ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
#elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
  ADMUX = _BV(MUX5) | _BV(MUX0) ;
#else
  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
#endif

  delay(2); // Wait for Vref to settle
  ADCSRA |= _BV(ADSC); // Start conversion
  while (bit_is_set(ADCSRA, ADSC)); // measuring

  uint8_t low  = ADCL; // must read ADCL first - it then locks ADCH
  uint8_t high = ADCH; // unlocks both

  long result = (high << 8) | low;

  result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
  return result; // Vcc in millivolts
}

LiquidCrystal lcd(8, 9, 10, 11, 12, 13); // the pins we use on the LCD
// pin 8 to RS, pin 9 to E, pin 10 to D4, pin 11 to D5, pin 12 to D6, pin 13 to D7.
// Ground to pins VSS,RW,K.
//+5vdc to pin VDD.
//220 ohm resistor between pins A and VDD.
//Potentiometer center pin to V0, positive pin to VDD, Negative pin to VSS.

const byte ROWS = 4;
const byte COLS = 3;
char keys[ROWS][COLS] = {
  {'1', '2', '3'},
  {'4', '5', '6'},
  {'7', '8', '9'},
  {'*', '0', '#'}
};
byte rowPins[ROWS] = {5, 4, 3, 2};
byte colPins[COLS] = {A0, A1, A2};

Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);

void setup() {
  pinMode(redled, OUTPUT);
  pinMode(yellowled, OUTPUT);
  pinMode(greenled, OUTPUT);
  lcd.begin(16, 2);
  Serial.begin(9600);

  readVcc();
  if (readVcc() >= 3800)
  {
    lcd.setCursor(0, 0);
    lcd.print("voltage is:");
    lcd.print(readVcc() / 1000.00);
    lcd.print("v");
    lcd.setCursor(0, 1);
    lcd.print("voltage good!");
    delay(3000);
  }

  if (readVcc() <= 3800)
  {
    lcd.setCursor(0, 0);
    lcd.print("voltage is:");
    lcd.print(readVcc() / 1000.00);
    lcd.print("v");
    lcd.setCursor(0, 1);
    lcd.print("replace battery!");
    delay(1000000);
  }

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Bomb activated!");
  lcd.setCursor(0, 1);
  lcd.print("Enter Code:");
  while (keycount < 4)
  {
    lcd.setCursor(keycount + 12, 1);
    lcd.blink();
    char armcode = keypad.getKey();
    armcode == NO_KEY;
    if (armcode != NO_KEY)
    {
      if ((armcode != '*') && (armcode != '#'))
      {
        lcd.print(armcode);
        tone(7, 5000, 100);
        password[keycount] = armcode;
        keycount++;
      }
    }
  }

  if (keycount == 4)
  {
    delay(500);
    lcd.noBlink();
    lcd.clear();
    lcd.home();
    lcd.print("Disarm Code is: ");
    lcd.setCursor(6, 1);
    lcd.print(password[0]);
    lcd.print(password[1]);
    lcd.print(password[2]);
    lcd.print(password[3]);
    delay(3000);
    lcd.clear();
  }
  lcd.setCursor(0, 0);
  lcd.print("Timer: HH:MM:SS");
  lcd.setCursor(0, 1);
  lcd.print("SET:   :  :");
  keycount = 5;

  while (keycount == 5)
  {
    char hourstens = keypad.getKey();
    lcd.setCursor(5, 1);
    lcd.blink();
    if (hourstens >= '0' && hourstens <= '9')
    {
      hourstenscode = hourstens - '0';
      tone(7, 5000, 100);
      lcd.print(hourstens);
      keycount++;
    }
  }

  while (keycount == 6)
  {
    char hoursones = keypad.getKey();
    lcd.setCursor(6, 1);
    lcd.blink();
    if (hoursones >= '0' && hoursones <= '9')
    {
      hoursonescode = hoursones - '0';
      tone(7, 5000, 100);
      lcd.print(hoursones);
      keycount++;
    }
  }

  while (keycount == 7)
  {
    char mintens = keypad.getKey();
    lcd.setCursor(8, 1);
    lcd.blink();
    if (mintens >= '0' && mintens <= '9')
    {
      mintenscode = mintens - '0';
      tone(7, 5000, 100);
      lcd.print(mintens);
      keycount++;
    }
  }

  while (keycount == 8)
  {
    char minones = keypad.getKey();
    lcd.setCursor(9, 1);
    lcd.blink();
    if (minones >= '0' && minones <= '9')
    {
      minonescode = minones - '0';
      tone(7, 5000, 100);
      lcd.print(minones);
      keycount++;
    }
  }

  while (keycount == 9)
  {
    char sectens = keypad.getKey();
    lcd.setCursor(11, 1);
    lcd.blink();
    if (sectens >= '0' && sectens <= '9')
    {
      sectenscode = sectens - '0';
      tone(7, 5000, 100);
      lcd.print(sectens);
      keycount = 10;
    }
  }

  while (keycount == 10)
  {
    char secones = keypad.getKey();
    lcd.setCursor(12, 1);
    lcd.blink();
    if (secones >= '0' && secones <= '9')
    {
      seconescode = secones - '0';
      tone(7, 5000, 100);
      lcd.print(secones);
      keycount = 11;
    }
  }

  if (keycount == 11);
  {
    Hours = (hourstenscode * 10) + hoursonescode;
    Minutes = (mintenscode * 10) + minonescode;
    Seconds = (sectenscode * 10) + seconescode;
    delay(100);
    lcd.noBlink();
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Timer set at:");
    if (Hours >= 10)
    {
      lcd.setCursor (7, 1);
      lcd.print (Hours);
    }
    if (Hours < 10)
    {
      lcd.setCursor (7, 1);
      lcd.write ("0");
      lcd.setCursor (8, 1);
      lcd.print (Hours);
    }
    lcd.print (":");

    if (Minutes >= 10)
    {
      lcd.setCursor (10, 1);
      lcd.print (Minutes);
    }
    if (Minutes < 10)
    {
      lcd.setCursor (10, 1);
      lcd.write ("0");
      lcd.setCursor (11, 1);
      lcd.print (Minutes);
    }
    lcd.print (":");

    if (Seconds >= 10)
    {
      lcd.setCursor (13, 1);
      lcd.print (Seconds);
    }

    if (Seconds < 10)
    {
      lcd.setCursor (13, 1);
      lcd.write ("0");
      lcd.setCursor (14, 1);
      lcd.print (Seconds);
    }
    delay(3000);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Press # to arm");
    delay (50);
    keycount = 12;
  }

  while (keycount == 12)
  {
    char armkey = keypad.getKey();

    if (armkey == '#')
    {
      tone(7, 5000, 100);
      delay(50);
      tone(7, 0, 100);
      delay(50);
      tone(7, 5000, 100);
      delay(50);
      tone(7, 0, 100);
      delay(50);
      tone(7, 5000, 100);
      delay(50);
      tone(7, 0, 100);
      lcd.clear();
      lcd.print ("Bomb Armed!");
      lcd.setCursor(0, 1);
      lcd.print("Countdown start");
      delay(3000);
      lcd.clear();
      keycount = 0;
    }
  }
}
void loop()
{
  timer();
  char disarmcode = keypad.getKey();

  if (disarmcode == '*')
  {
    tone(7, 5000, 100);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Code: ");

    while (keycount < 4)
    {
      timer();

      char disarmcode = keypad.getKey();
      if (disarmcode == '#')
      {
        tone(7, 5000, 100);
        keycount = 0;
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Code: ");
      }
      else if (disarmcode != NO_KEY)
      {
        lcd.setCursor(keycount + 7, 0);
        lcd.blink();
        lcd.print(disarmcode);
        entered[keycount] = disarmcode;
        keycount++;
        tone(7, 5000, 100);
        delay(100);
        lcd.noBlink();
        lcd.setCursor(keycount + 6, 0);
        lcd.print("*");
        lcd.setCursor(keycount + 7, 0);
        lcd.blink();
      }
    }

    if (keycount == 4)
    {
      if (entered[0] == password[0] && entered[1] == password[1] && entered[2] == password[2] && entered[3] == password[3])
      {
        lcd.noBlink();
        lcd.clear();
        lcd.home();
        lcd.print("Bomb Defused!");
        lcd.setCursor(0, 1);
        lcd.print("Great job!");
        keycount = 0;
        digitalWrite(greenled, HIGH);
        delay(15000);
        lcd.clear();
        lcd.setCursor(0, 1);
        lcd.print("Reset the Bomb");
        delay(1000000);
      }
      else
      {
        lcd.noBlink();
        lcd.clear();
        lcd.home();
        lcd.print("Wrong Password!");
        trycount++;

        if (Hours > 0)
        {
          Hours = Hours / 2;
        }

        if (Minutes > 0)
        {
          Minutes = Minutes / 2;
        }
        if (Seconds > 0)
        {
          Seconds = Seconds / 2;
        }
        if (trycount == 2)
        {
          interval = interval / 10;
        }
        if (trycount == 3)
        {
          Minutes = Minutes - 59;
          Hours = Hours - 59;
          Seconds = Seconds - 59;
        }
        delay(1000);
        keycount = 0;
      }
    }
  }
}

void timer()
{
  Serial.print(Seconds);
  Serial.println();

  if (Hours <= 0)
  {
    if ( Minutes < 0 )
    {
      lcd.noBlink();
      lcd.clear();
      lcd.home();
      lcd.print("The Bomb Has ");
      lcd.setCursor (0, 1);
      lcd.print("Exploded!");

      while (Minutes < 0)
      {
        digitalWrite(redled, HIGH);
        tone(7, 7000, 100);
        delay(100);
        digitalWrite(redled, LOW);
        tone(7, 7000, 100);
        delay(100);
        digitalWrite(yellowled, HIGH);
        tone(7, 7000, 100);
        delay(100);
        digitalWrite(yellowled, LOW);
        tone(7, 7000, 100);
        delay(100);
        digitalWrite(greenled, HIGH);
        tone(7, 7000, 100);
        delay(100);
        digitalWrite(greenled, LOW);
        tone(7, 7000, 100);
        delay(100);
      }
    }
  }
  lcd.setCursor (0, 1);
  lcd.print ("Timer:");

  if (Hours >= 10)
  {
    lcd.setCursor (7, 1);
    lcd.print (Hours);
  }
  if (Hours < 10)
  {
    lcd.setCursor (7, 1);
    lcd.write ("0");
    lcd.setCursor (8, 1);
    lcd.print (Hours);
  }
  lcd.print (":");

  if (Minutes >= 10)
  {
    lcd.setCursor (10, 1);
    lcd.print (Minutes);
  }
  if (Minutes < 10)
  {
    lcd.setCursor (10, 1);
    lcd.write ("0");
    lcd.setCursor (11, 1);
    lcd.print (Minutes);
  }
  lcd.print (":");

  if (Seconds >= 10)
  {
    lcd.setCursor (13, 1);
    lcd.print (Seconds);
  }

  if (Seconds < 10)
  {
    lcd.setCursor (13, 1);
    lcd.write ("0");
    lcd.setCursor (14, 1);
    lcd.print (Seconds);
  }

  if (Hours < 0)
  {
    Hours = 0;
  }

  if (Minutes < 0)
  {
    Hours --;
    Minutes = 59;
  }

  if (Seconds < 1)
  {
    Minutes --;
    Seconds = 59;
  }

  if (Seconds > 0)
  {
    unsigned long currentMillis = millis();

    if (currentMillis - secMillis > interval)
    {
      tone(7, 7000, 50);
      secMillis = currentMillis;
      Seconds --;
      digitalWrite(yellowled, HIGH);
      delay(10);
      digitalWrite(yellowled, LOW);
      delay(10);
    }
  }
}

Comments

Author

Default
draymond
  • 1 project
  • 0 followers

Additional contributors

  • Helping with the timer input by aarg

Published on

January 7, 2018

Members who respect this project

12243401 10205400323863387 9222679226887566571 n

and 10 others

See similar projects
you might like

Similar projects you might like

Arduino Prop Bomb

Project tutorial by Victor Altamirano

  • 3,847 views
  • 1 comment
  • 15 respects

Arduino Arisoft Time Bomb Game

Project showcase by Danny van den Brande

  • 15,702 views
  • 22 comments
  • 41 respects

Arduino Airsoft Time Bomb with Button, Speaker and 3 LEDs

Project showcase by Nashboss100

  • 3,088 views
  • 18 comments
  • 11 respects

QUAKE 3 Railgun Replica Prop

Project showcase by Oscar Gonzalez

  • 1,027 views
  • 1 comment
  • 7 respects

Smart Garden

Project showcase by patel Dipen

  • 38,350 views
  • 17 comments
  • 85 respects

Arduino UNO High Precision Counting Scale

Project showcase by Fedeasche

  • 17,894 views
  • 10 comments
  • 47 respects
Add projectSign up / Login