#include <Wire.h>
#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
/*
Arduino Bomb Pro
The circuit:
* More info at : http://yin.mainstreamds.com/
If you need some help mail me to [email protected]
Original code by
created 4,Sep, 2010
Modified 11 Nov 2015
by Ignacio Lillo
edited by centrifuga
*/
LiquidCrystal_I2C lcd(0x27,16,2);
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
{'1','2','3','a'},
{'4','5','6','b'},
{'7','8','9','c'},
{'*','0','#','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 );
char codeInput[8];
byte time[4];
boolean refresh = true; //1 refresh one time...
char password[8];
int key = -1;
char lastKey;
char var;
boolean passwordEnable = false;
//Buttons for lcd shield
char BT_RIGHT = '4'; // ne koristi se
char BT_UP = 'a'; // navigacija menija
char BT_DOWN = 'b';
char BT_LEFT = '6'; // ne koristi se
char BT_SEL = 'd'; // CONFIRM
char BT_CANCEL = 'c'; // CANCEL
char BT_DEFUSER = 'x'; // ne koristi se
char BT_EASTER = '#'; // ne koristi se
char BT_MENU = '*';
//leds
const byte REDLED = 13;
const byte BLUELED = 12;
//const byte BLUELED = 12;
//RELAYPIN
boolean relayEnable = false;
const byte RELAYPIN = 11;
//IS VERY IMPORTANT THAT YOU TEST THIS TIME. BY DEFAULT IS IN 1 SEC. THAT IS NOT TOO MUCH. SO TEST IT!
const int RELAY_TIME = 5000;
//TIME INTS
int GAMEHOURS = 0;
int GAMEMINUTES = 45;
int BOMBMINUTES = 4;
int ACTIVATESECONDS = 5;
boolean endGame = false;
boolean sdStatus = false; //search and destroy game enable used in config
boolean saStatus = false; //same but SAbotaghe
boolean doStatus = false; //for DEmolition
boolean start = true;
boolean IRRemote = false;
const byte passwordSize = 4;
// DKey = D na keypadu CKey = C na keypadu
boolean DKey;
boolean CKey;
// SOUND TONES
boolean soundEnable = true;
boolean neutralizeZones = false;
boolean totalTime = false;
const byte tonepin = 10; // Pin 10 for the sound
int alarmTone1 = 1319;
int alarmTone2 = 1750;
int activeTone = 1250;
int errorTone = 100;
unsigned long iTime;
unsigned long timeCalcVar;
unsigned long redTime;
unsigned long blueTime;
unsigned long iZoneTime;//initial time for zone
byte team=0; // 0 = neutral, 1 = blue team, 2 = red team
void setup(){
uint8_t p1[8] = {
0x0C,
0x0A,
0x0C,
0x08,
0x03,
0x14,
0x08,
0x08
};
lcd.begin(16, 2);
lcd.createChar(9,p1);
lcd.backlight();
Serial.begin(9600);
lcd.setCursor(1,0);
lcd.print(" P.A.S.");// you can add your team name or someting cool
lcd.setCursor(2,1);
lcd.print("Lepoglava");
lcd.setCursor(1,1);
delay(500);
lcd.print(" ");// you can add your team name or someting cool
// 1567, 1760, 1046, 1760, 1108, 1108, 1046
lcd.setCursor(15,1);
lcd.write(9);
cls();
delay(1000);
lcd.setCursor(1,0);
lcd.print(" NEVER GONNA ");
lcd.setCursor(1,1);
tone(tonepin,783,150);
delay(150);
tone(tonepin,880,150);
delay(150);
tone(tonepin,1046,150);
delay(150);
tone(tonepin,880,150);
delay(150);
lcd.setCursor(1,1);
lcd.print(" GIVE YOU UP ");
tone(tonepin,1318,400);
delay(500);
tone(tonepin,1318,250);
delay(400);
tone(tonepin,1174,780);
delay(1000);
cls();
lcd.setCursor(1,0);
lcd.print(" NEVER GONNA ");
tone(tonepin,783,150);
delay(150);
tone(tonepin,880,150);
delay(150);
tone(tonepin,1046,150);
delay(150);
tone(tonepin,880,150);
delay(150);
lcd.setCursor(1,1);
lcd.print(" LET YOU DOWN ");
tone(tonepin,1174,400);
delay(500);
tone(tonepin,1174,250);
delay(400);
tone(tonepin,1046,600);
delay(800);
// keypad
keypad.setHoldTime(50);
keypad.setDebounceTime(50);
keypad.addEventListener(keypadEvent);
// PinModes
pinMode(BLUELED, OUTPUT);
pinMode(REDLED, OUTPUT);
pinMode(RELAYPIN, OUTPUT);
// CONFIGURE THE BARS OF PROGRESS BAR
byte bar1[8] = {
B10000,
B10000,
B10000,
B10000,
B10000,
B10000,
B10000,
B10000,
};
byte bar2[8] = {
B11000,
B11000,
B11000,
B11000,
B11000,
B11000,
B11000,
B11000,
};
byte bar3[8] = {
B11100,
B11100,
B11100,
B11100,
B11100,
B11100,
B11100,
B11100,
};
byte bar4[8] = {
B11110,
B11110,
B11110,
B11110,
B11110,
B11110,
B11110,
B11110,
};
byte bar5[8] = {
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
};
byte up[8] = {
B00000,
B00100,
B01110,
B10101,
B00100,
B00100,
B00100,
B00000
};
byte down[8] = {
B00000,
B00100,
B00100,
B00100,
B10101,
B01110,
B00100,
B00000
};
lcd.createChar(0,bar1);
lcd.createChar(1,bar2);
lcd.createChar(2,bar3);
lcd.createChar(3,bar4);
lcd.createChar(4,bar5);
lcd.createChar(5,up);
lcd.createChar(6,down);
}
void loop(){
menuPrincipal();
}
void keypadEvent(KeypadEvent key){
switch (keypad.getState()){
case RELEASED:
switch (key){
case 'd': DKey=false;
break;
case 'c': CKey=false;
break;
}
break;
case HOLD:
switch (key){
case 'd': DKey= true;
break;
case 'c': CKey=true;
break;
}
break;
}
}