Introduction: Arduino Defuseable Bomb, Perfect for Airsoft Games! (with Timer, LCD, Keypad, Sound and More!)
Hello
This is a project I made a long time ago, but decided to upload anyways, feel free to ask me about it!
The bomb has several features:
- Password input by keypad to arm the bomb
- Timer/count down
- Sound
- Flashy LEDs
- Defusing via the password
- LCD display
- Keypad
- Simple to edit and change
So to get started you would need:
- Arduino
- LCD (I used a 16x2 from sparkfun)
- Potentiometer for the contrast on the LCD
- Keypad (again from sparkfun)
- Jumperwires
- Resistors for the LEDs (I used 330 Ohm)
- Piezo/buzzer
- LEDs
Step 1: Assembly
Connect the components as according to the circuit schematic
Step 2: Upload the Code
Upload the bomb project4 code to your arduino, and add the following libraries: Keypad, Tone, and liquid crystal to your libraries folder in the arduino folder
and now you're ready to use the bomb!
First edit the time in the code, to match your needs, then start the arduino and enter your desired password, then the bomb timer will start, and you can press the * to begin defusing the bomb, if you press a wrong key, pressing # will delete what you've written. If you write a wrong password, or the timer reaches 0, the bomb will "explode"!
Feel free to ask :)

Participated in the
Microcontroller Contest
207 Comments
8 years ago on Introduction
thank you :D it worked like a charm: https://www.youtube.com/watch?v=5O5KRUmsD6o&feature=youtu.be
Reply 8 years ago on Introduction
Glad you found it useful! Your prop looks great!
Reply 7 years ago on Introduction
Hey, I am having a issue with the LCD screen. When I turn it on nothing is being displayed on the screen, the keypad, LED's and buzzer work fine, when I enter the code and it start counting I am able to enter password again after the * and it is being defused or explode but the LCD screen itself does not display anything. I am including the picture of how the LCD is displayed
Reply 7 years ago
I'm having the same issue
Reply 7 years ago
hi, have you found a solution i have your same problem.....the lcd makes only a long line like in your photos...
Reply 7 years ago
did you find a solution?
Reply 7 years ago on Introduction
do you have Potentiometer for the contrast on the LCD ?
Reply 7 years ago on Introduction
I may found the reason for the LCD to not work correctly.....
The schematics of the LCD does not show which order are the pins, if they are VSS, VDD, VO, RS, RW, E, D0, D1, D2, D3, D4, D5, D6 ,D7, A, K, or other way round... I will Re-solder them and we will see if it helps.
Reply 8 years ago
Hi
Do you have any detailed photos of your wiring ? I'm having some trouble getting this to work
7 months ago
i'm trying to make one as i type, got case and keypad fitted. what leds are recommended? all red, 3v?
need easiest code for bomb defuse also. have arduino, potentiometer,leds,keypad,
my display only has the multiple pins, i don't have an I2c module, does this matter or do i need to get one?
thanks jason
Question 8 months ago
#include <Wire.h>
/////////////////////////////
// Airsoft Bomb //
// by Malthe Falkenstjerne //
/////////////////////////////
#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
int Scount = 0; // count seconds
int Mcount = 10; // count minutes
int Hcount = 0; // count hours
int DefuseTimer = 0; // set timer to 0
long secMillis = 0; // store last time for second add
long interval = 1000; // interval for seconds
char password[4]; // number of characters in our password
int currentLength = 0; //defines which number we are currently writing
int i = 0;
char entered[4];
String action;
LiquidCrystal_I2C lcd(0x27, 16, 2); // the pins we use on the LCD
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {3, 4, 5, 6}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {7, 8, 9, 10}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup(){
lcd.init();
lcd.backlight();
lcd.begin(16, 2);
Serial.begin(9600);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Enter Code: ");
while (currentLength < 4)
{
lcd.setCursor(currentLength + 6, 1);
lcd.cursor();
char key = keypad.getKey();
key == NO_KEY;
if (key != NO_KEY)
{
if ((key != '*')&&(key != '#'))
{
lcd.print(key);
password[currentLength] = key;
currentLength++;
}
}
}
if (currentLength == 4)
{
delay(500);
lcd.noCursor();
lcd.clear();
lcd.home();
lcd.print("You've Entered: ");
lcd.setCursor(6,1);
lcd.print(password[0]);
lcd.print(password[1]);
lcd.print(password[2]);
lcd.print(password[3]);
delay(3000);
lcd.clear();
currentLength = 0;
}
}
void loop()
{
timer();
char key2 = keypad.getKey(); // get the key
if (key2 == '*')
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Code: ");
while (currentLength < 4)
{
timer();
char key2 = keypad.getKey();
if (key2 == '#')
{
currentLength = 0;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Code: ");
}
else
if (key2 != NO_KEY)
{
lcd.setCursor(currentLength + 7, 0);
lcd.cursor();
lcd.print(key2);
entered[currentLength] = key2;
currentLength++;
delay(100);
lcd.noCursor();
lcd.setCursor(currentLength + 6, 0);
lcd.print("*");
lcd.setCursor(currentLength + 7, 0);
lcd.cursor();
}
}
if (currentLength == 4)
{
if (entered[0] == password[0] && entered[1] == password[1] && entered[2] == password[2] && entered[3] == password[3])
{
lcd.noCursor();
lcd.clear();
lcd.home();
lcd.print("Bomb Defused");
delay(10000);
lcd.setCursor(0,1);
lcd.print("Reset the Bomb");
delay(1000000);
}
else
{
lcd.noCursor();
lcd.clear();
lcd.home();
lcd.print("Wrong Password!");
delay(5000);
if (Hcount > 0)
{
Hcount = Hcount - 1;
}
if (Mcount > 0)
{
Mcount = Mcount - 59;
}
if (Scount > 0)
{
Scount = Scount - 59;
}
delay(1500);
currentLength = 0;
}
}
}
}
void timer()
{
Serial.print(Scount);
Serial.println();
if (Hcount <= 0)
{
if ( Mcount < 0 )
{
lcd.noCursor();
lcd.clear();
lcd.home();
lcd.print("The Bomb Has ");
lcd.setCursor (0,1);
lcd.print("Exploded!");
while (Mcount < 0)
{
delay(100);
}
}
}
lcd.setCursor (0,1); // sets cursor to 2nd line
lcd.print ("Timer:");
if (Hcount >= 10)
{
lcd.setCursor (7,1);
lcd.print (Hcount);
}
if (Hcount < 10)
{
lcd.setCursor (7,1);
lcd.write ("0");
lcd.setCursor (8,1);
lcd.print (Hcount);
}
lcd.print (":");
if (Mcount >= 10)
{
lcd.setCursor (10,1);
lcd.print (Mcount);
}
if (Mcount <= 10)
{
lcd.setCursor (10,1);
lcd.write ("0");
lcd.setCursor (11,1);
lcd.print (Mcount);
}
lcd.print (":");
if (Scount >= 10)
{
lcd.setCursor (13,1);
lcd.print (Scount);
}
if (Scount <= 10)
{
lcd.setCursor (13,1);
lcd.write ("0");
lcd.setCursor (14,1);
lcd.print (Scount);
}
if (Hcount <0)
{
Hcount = 0;
}
if (Mcount <0)
{
Hcount --;
Mcount = 59;
}
if (Scount <1) // if 60 do this operation
{
Mcount --; // add 1 to Mcount
Scount = 59; // reset Scount
}
if (Scount >= 0) // do this oper. 59 times
{
unsigned long currentMillis = millis();
if(currentMillis - secMillis > interval)
{
delay(500);
}
}
}
Question 11 months ago
How do i set time
Question 11 months ago
Its working with oled?
4 years ago
Has anyone built a ruggedized kit, so that it could be used by Airsoft gamers?
It would be awesome if they looked like the attached..
Reply 1 year ago
I made a simplified version with just a C4 look. The timer counts 30 seconds, and then activates a smoke bomb to simulate detonation. You can see it working (the edited version) in my channel's trailer at minute 1:14. The bomb is at minute 1:25 (it is actually 2 separate shots, but you see it activating fireworks in the second shot; the bomb is on the floor and the fireworks are on top of the structure).
https://www.youtube.com/watch?v=dS4S4JrRY4E&t=4s
I also have the full version that is in a rugged (pelican type) case. That one we made a missile launcher to go with it and sometimes play with the bomb controlling the missile launcher. The missile launcher fires 2 fireworks to simulate missiles (looks VERY realistic!). You can see the bomb case in the window in the picture of the missile launcher.
Question 2 years ago on Introduction
I figured it out, code and all. Everything works with I2C LCD ... Thanks
Answer 2 years ago
Hi, would you be able to share? I'm getting errors on lcd not declared on one of the tabs? Actually saying that, i'm getting errors thrown up everywhere! TIA
Reply 2 years ago
Show me your code. I'll try to pick out the error for you. Is it an I2C?
Reply 2 years ago
thank you very much yes it is i2c.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
//#include <LiquidCrystal.h>
#include <Tone.h>
#define pound 14
Tone tone1;
int Scount = 12; // count seconds
int Mcount = 10; // count minutes
int Hcount = 0; // count hours
int DefuseTimer = 0; // set timer to 0
long secMillis = 0; // store last time for second add
long interval = 1000; // interval for seconds
char password[4]; // number of characters in our password
int currentLength = 0; //defines which number we are currently writing
int i = 0;
char entered[4];
int ledPin = 4; //red led
int ledPin2 = 3; //yellow led
int ledPin3 = 2; //green led
//LiquidCrystal lcd(7,8,10,11,12,13); // the pins we use on the LCD
//and add a cable to pin 6 which is pin 1 on the keypad.
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {A7, A8, A9, A10}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {A11, A12, 14, 15}; //connect to the column pinouts of the keypad
//Pins 8, 7, 6, 5 on the keypad should be connected to digital pins A0, 5, A1, A2 on //the Arduino.
//Pins 4, 3, 2, 1 on the keypad should be connected to digital pins A3, A4, A5, 6 on //the Arduino.
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
//LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7);
//LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display
void setup() {
pinMode(ledPin, OUTPUT); // sets the digital pin as output
pinMode(ledPin2, OUTPUT); // sets the digital pin as output
pinMode(ledPin3, OUTPUT); // sets the digital pin as output
tone1.begin(9);
Serial.begin(9600);
lcd.init();
lcd.begin(16, 2);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Enter Code: ");
while (currentLength < 4)
{
lcd.setCursor(currentLength + 6, 1);
lcd.cursor();
char key = keypad.getKey();
key == NO_KEY;
if (key != NO_KEY)
{
if ((key != '*') && (key != '#'))
{
lcd.print(key);
password[currentLength] = key;
currentLength++;
tone1.play(NOTE_C6, 200);
}
}
}
if (currentLength == 4)
{
delay(500);
lcd.noCursor();
lcd.clear();
lcd.home();
lcd.print("You've Entered: ");
lcd.setCursor(6, 1);
lcd.print(password[0]);
lcd.print(password[1]);
lcd.print(password[2]);
lcd.print(password[3]);
tone1.play(NOTE_E6, 200);
delay(3000);
lcd.clear();
currentLength = 0;
}
}
void loop()
{
timer();
char key2 = keypad.getKey(); // get the key
if (key2 == '*')
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Code: ");
while (currentLength < 4)
{
timer();
char key2 = keypad.getKey();
if (key2 == '#')
{
currentLength = 0;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Code: ");
}
else if (key2 != NO_KEY)
{
lcd.setCursor(currentLength + 7, 0);
lcd.cursor();
lcd.print(key2);
entered[currentLength] = key2;
currentLength++;
tone1.play(NOTE_C6, 200);
delay(100);
lcd.noCursor();
lcd.setCursor(currentLength + 6, 0);
lcd.print("*");
lcd.setCursor(currentLength + 7, 0);
lcd.cursor();
}
}
if (currentLength == 4)
{
if (entered[0] == password[0] && entered[1] == password[1] && entered[2] == password[2] && entered[3] == password[3])
{
lcd.noCursor();
lcd.clear();
lcd.home();
lcd.print("Bomb Defused");
currentLength = 0;
digitalWrite(ledPin3, HIGH);
delay(2500);
lcd.setCursor(0, 1);
lcd.print("Reset the Bomb");
delay(1000000);
}
else
{
lcd.noCursor();
lcd.clear();
lcd.home();
lcd.print("Wrong Password!");
if (Hcount > 0)
{
Hcount = Hcount - 1;
}
if (Mcount > 0)
{
Mcount = Mcount - 59;
}
if (Scount > 0)
{
Scount = Scount - 59;
}
delay(1500);
currentLength = 0;
}
}
}
}
void timer()
{
Serial.print(Scount);
Serial.println();
if (Hcount <= 0)
{
if ( Mcount < 0 )
{
lcd.noCursor();
lcd.clear();
lcd.home();
lcd.print("The Bomb Has ");
lcd.setCursor (0, 1);
lcd.print("Exploded!");
while (Mcount < 0)
{
digitalWrite(ledPin, HIGH); // sets the LED on
tone1.play(NOTE_A2, 90);
delay(100);
digitalWrite(ledPin, LOW); // sets the LED off
tone1.play(NOTE_A2, 90);
delay(100);
digitalWrite(ledPin2, HIGH); // sets the LED on
tone1.play(NOTE_A2, 90);
delay(100);
digitalWrite(ledPin2, LOW); // sets the LED off
tone1.play(NOTE_A2, 90);
delay(100);
digitalWrite(ledPin3, HIGH); // sets the LED on
tone1.play(NOTE_A2, 90);
delay(100);
digitalWrite(ledPin3, LOW); // sets the LED off
tone1.play(NOTE_A2, 90);
delay(100);
}
}
}
{
lcd.setCursor (0, 1); // sets cursor to 2nd line
lcd.print ("Timer:");
if (Hcount >= 10)
{
lcd.setCursor (7, 1);
lcd.print (Hcount);
}
if (Hcount < 10)
{
lcd.setCursor (7, 1);
lcd.write ("0");
lcd.setCursor (8, 1);
lcd.print (Hcount);
}
lcd.print (":");
if (Mcount >= 10)
{
lcd.setCursor (10, 1);
lcd.print (Mcount);
}
if (Mcount < 10)
{
lcd.setCursor (10, 1);
lcd.write ("0");
lcd.setCursor (11, 1);
lcd.print (Mcount);
}
lcd.print (":");
if (Scount >= 10)
{
lcd.setCursor (13, 1);
lcd.print (Scount);
}
if (Scount < 10)
{
lcd.setCursor (13, 1);
lcd.write ("0");
lcd.setCursor (14, 1);
lcd.print (Scount);
}
if (Hcount < 0)
{
Hcount = 0;
}
if (Mcount < 0)
{
Hcount --;
Mcount = 59;
}
if (Scount < 1) // if 60 do this operation
{
Mcount --; // add 1 to Mcount
Scount = 59; // reset Scount
}
if (Scount > 0) // do this oper. 59 times
{
unsigned long currentMillis = millis();
if (currentMillis - secMillis > interval)
{
tone1.play(NOTE_G5, 200);
secMillis = currentMillis;
Scount --; // add 1 to Scount
digitalWrite(ledPin2, HIGH); // sets the LED on
delay(10); // waits for a second
digitalWrite(ledPin2, LOW); // sets the LED off
delay(10); // waits for a second
//lcd.clear();
}
}
}
Reply 2 years ago
you have the LCD declared twice. you also need to make sure it's address is actually 0x27... if that's not the proper address, it won't display. there is an I2C test script out there that will tell you what the proper address is. If it's an I2C display, you only need two pins to run it. Make sure the pins are in the proper order. I reversed them once and it drove me crazy till I figured it out.
Here is what I have:
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <Keypad.h>
#include <LCD.h> //this needs to be fixed.
// Sets the piezo buzzer sounds
#include <Tone.h>
#define pound 10
int soundPin = 10; //assigns buzzer sound pin to digital 10
Tone tone1;
//sets the timer integers and counts
int Scount = 0; // count seconds
int Mcount = 30; // count minutes
int Hcount = 0; // count hours
int DefuseTimer = 0; // set timer to 0
long secMillis = 0; // stores previous time for new count after timeout expires
long interval = 1000; // the millisecond interval for number of seconds
char password[4]; // sets the password length
int currentLength = 0; //defines the number being input
int i = 0;
char entered[4];
int ledPin = 11; //defines the red led at digital pin 11
int ledPin2 = 12; //defines the yellow led at digital pin 12
int ledPin3 = 13; //defines the green LED at digital pin 13
LiquidCrystal_I2C lcd(0x27,A4,A5); // the pins we use for the I2C LCD display **********************
//sets up and configures the 4x4 keypad
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
{'1','4','7','*'},
{'2','5','8','0'},
{'3','6','9','#'},
{'A','B','C','D'}
};
byte rowPins[ROWS] = {6, 7, 8, 9}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {2, 3, 4, 5}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void(* resetFunc) (void) = 0;
void setup(){
pinMode(ledPin, OUTPUT); // sets the digital pin as output
pinMode(ledPin2, OUTPUT); // sets the digital pin as output
pinMode(ledPin3, OUTPUT); // sets the digital pin as output
tone1.begin(10);
lcd.begin(16, 2);
Serial.begin(9600);
lcd.init();
lcd.backlight();
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Set Code: ");
while (currentLength < 4) //as long a the code is less than 4 characters, then...
{
lcd.setCursor(currentLength + 6, 1); //displays current length typed in on line 1, position 6
lcd.cursor();
char key = keypad.getKey();
key == NO_KEY;
if (key != NO_KEY)
{
if ((key != '*')&&(key != '#')) //if error while entering code, press '#' to erase and begin again
{
lcd.print(key);
password[currentLength] = key;
currentLength++;
tone1.play(2400,30);
//tone1.play(NOTE_C6, 100); //plays tone when keys are pressed
digitalWrite(ledPin, HIGH); // sets the LED on
delay(10); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(10); // waits for a second
}
}
}
if (currentLength == 4) //when the length hits 4 characters, do this below.
{
delay(500);
lcd.noCursor();
lcd.clear();
lcd.home();
lcd.print(" Code Input: ");
lcd.setCursor(6,1);
lcd.print(password[0]);
lcd.print(password[1]);
lcd.print(password[2]);
lcd.print(password[3]);
tone1.play(2400,500);
delay(3000);
lcd.clear();
currentLength = 0;
}
}
void loop()
{
timer();
char key2 = keypad.getKey(); // the process begins with 'get the key'
if (key2 == '*') // when the '*' is pressed, the display asks for the code to be input
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Code: ");
while (currentLength < 4) // accepts input as long as the code is less than 4 characters
{
timer();
char key2 = keypad.getKey();
if (key2 == '#')
{
currentLength = 0;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Code: ");
}
else
if (key2 != NO_KEY)
{
lcd.setCursor(currentLength + 7, 0);
lcd.cursor();
lcd.print(key2);
entered[currentLength] = key2;
currentLength++;
tone1.play(2400, 100);
delay(100);
lcd.noCursor();
lcd.setCursor(currentLength + 6, 0); // shows '*' in display for code
digitalWrite(ledPin, HIGH); // sets the LED on
delay(10); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(10); // waits for a second
lcd.print("*");
lcd.setCursor(currentLength + 7, 0);
lcd.cursor();
}
}
if (currentLength == 4) //once 4 keys are pressed, or entered, the password is set
{
if (entered[0] == password[0] && entered[1] == password[1] && entered[2] == password[2] && entered[3] == password[3]) //if the buttons pressed are the correct password, the device disarms
{
lcd.noCursor();
lcd.clear();
lcd.home();
lcd.print("Weapon Disarmed"); // informs you that the device is disarmed and you win
currentLength = 0;
tone1.play(2400, 1000);
digitalWrite(ledPin3, HIGH);
delay(2500);
lcd.setCursor(0,1);
lcd.print("Core Pwr Down"); //tells you to power down or reset the device
delay(15000);
digitalWrite(ledPin3, LOW);
resetFunc();
delay(1000000 );
}
else
{
lcd.noCursor();
lcd.clear();
lcd.home();
lcd.print("Code Incorrect.."); // if you enter an incorrect code...
if (Hcount > 0)
{
Hcount = Hcount - 1;
}
if (Mcount > 0)
{
Mcount = Mcount - 59;
}
if (Scount > 0)
{
Scount = Scount - 59;
}
delay(1500);
currentLength = 0;
}
}
}
}
void timer()
{
Serial.print(Scount);
Serial.println();
if (Hcount <= 0)
{
if ( Mcount < 0 )
{
lcd.noCursor();
lcd.clear();
lcd.home();
lcd.print(" Device");
lcd.setCursor (0,1);
lcd.print("***DETONATED!*** ");
while (Mcount < 0) // incorrect code causes detonation, flashing red, yellow, green LEDs, and playing tone
{
digitalWrite(ledPin, HIGH); // sets the LED on
tone1.play(NOTE_A2, 90);
delay(100);
digitalWrite(ledPin, LOW); // sets the LED off
tone1.play(NOTE_A2, 90);
delay(100);
digitalWrite(ledPin2, HIGH); // sets the LED on
tone1.play(NOTE_A2, 90);
delay(100);
digitalWrite(ledPin2, LOW); // sets the LED off
tone1.play(NOTE_A2, 90);
delay(100);
digitalWrite(ledPin3, HIGH); // sets the LED on
tone1.play(NOTE_A2, 90);
delay(100);
digitalWrite(ledPin3, LOW); // sets the LED off
tone1.play(NOTE_A2, 90);
delay(100);
}
}
}
lcd.setCursor (0,1); // sets cursor to 2nd line
lcd.print ("Timer:");
if (Hcount >= 10)
{
lcd.setCursor (7,1);
lcd.print (Hcount);
}
if (Hcount < 10)
{
lcd.setCursor (7,1);
lcd.write ("0");
lcd.setCursor (8,1);
lcd.print (Hcount);
}
lcd.print (":");
if (Mcount >= 10)
{
lcd.setCursor (10,1);
lcd.print (Mcount);
}
if (Mcount < 10)
{
lcd.setCursor (10,1);
lcd.write ("0");
lcd.setCursor (11,1);
lcd.print (Mcount);
}
lcd.print (":");
if (Scount >= 10)
{
lcd.setCursor (13,1);
lcd.print (Scount);
}
if (Scount < 10)
{
lcd.setCursor (13,1);
lcd.write ("0");
lcd.setCursor (14,1);
lcd.print (Scount);
}
if (Hcount <0)
{
Hcount = 0;
}
if (Mcount <0)
{
Hcount --;
Mcount = 59;
}
if (Scount <1) // if 60 do this operation
{
Mcount --; // add 1 to Mcount
Scount = 59; // reset Scount
}
if (Scount > 0) // do this oper. 59 times
{
unsigned long currentMillis = millis();
if(currentMillis - secMillis > interval) // flashes yellow LED during countdown
{
tone1.play(4000, 100);
secMillis = currentMillis;
Scount --; // add 1 to Scount
digitalWrite(ledPin2, HIGH); // sets the LED on
delay(10); // waits for a second
digitalWrite(ledPin2, LOW); // sets the LED off
delay(10); // waits for a second
lcd.clear();
}
}
}