/***************************************************************************************************
****************************************************************************************************
****************************** ARDUINO AIRSOFT BOMB MULTIGAME MODE ********************************
****************************** VERSION FIRMWARE V 3.5.2 CMLABTECH ********************************
****************************************************************************************************
****************************************************************************************************
****************************** CREATO, EDITATO, PROGETTATO ********************************
****************************** E REALIZZATO DA ********************************
****************************** ********************************
****************************** CIRO MARCIANO ********************************
****************************************************************************************************
****************************************************************************************************
NOTE DI VERSIONE:
PIN COLLEGAMENTI:
PIN DISPLAY:
SDA = A4
SCL = A5
VCC = +5V
GND = GND
PIN NEOPIXEL LED:
ARMLED = D02
DOWN LED = D08
PWRLED = D09
UPLED = D10
ROUNDLED = D11
VIRUSLED = D12
SOUND:
BUZZER = D13
REPEAT = D01
SIRENA = D03
Collegamenti Tastiera
Tastiera PIN Righe: Tastiera PIN Colonne:
CAVO 1 - PIN A0 CAVO 5 - PIN D4
CAVO 2 - PIN A1 CAVO 6 - PIN D5
CAVO 3 - PIN A2 CAVO 7 - PIN D6
CAVO 4 - PIN A3 CAVO 8 - PIN D7
PULSANTI MODALITA' BASE:
PULSANTE ROSSO = A3
PULSANTE VERDE = A2
CAVO COMUNE = D7
CAVO COMUNE = D7
*/
// Librerie:
#include <Wire.h>
#include <FastLED.h>
#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
//Indirizzo I2C Display LCD
LiquidCrystal_I2C lcd(0x27, 16, 2);
//Setup Tastierino Numerico
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] = {A0, A1, A2, A3}; //Sempre Attivato
byte colPins[COLS] = {4, 5, 6, 7}; //Attivato solo nella Simulazione WokWi
//byte rowPins[ROWS] = {A3, A2, A1, A0}; //Sempre Disattivato
//byte colPins[COLS] = {7, 6, 5, 4}; //Attivato solo nella realizzazione Fisica
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
//Variabili varie
char enteredText[8] = {0}; // Inizializzazione
char password[8] = {0}; // Inizializzazione
int key = -1; // Inizializzazione
void (*Riavvia)(void) = 0; // Inizializzazione
char lastKey = '\0'; // Inizializzazione
char var = '\0'; // Inizializzazione
boolean passwordEnable = false; // Inizializzazione
int failedAttempts = 0; // Inizializzazione
int PASSTRY = 3; // Valore di default
char BT_RIGHT = '4';
char BT_UP = 'a';
char BT_DOWN = 'b';
char BT_LEFT = '6';
char BT_SEL = 'd';
char BT_CANCEL = 'c';
char BT_DEFUSER = 'x'; // not implemented
//Neopixel Config
#define ARMLED 2 //definisce il PIN per l' ARM LED
#define DOWNLED 8 //definisce il PIN per la Down LED
#define PWRLED 9 //definisce il PIN per il Power LED
#define UPLED 10 //definisce il PIN per la Up LED
#define ROUNDLED 11 //definisce il PIN per la Round LED
#define VIRUSLED 12 //definisce il PIN per il Virus LED
#define ARM_NUM 1 //definisce il numero di led dell' ARM LED
#define DOWN_NUM 8 //definisce il numero di led della Down LED
#define PWR_NUM 1 //definisce il numero di led del Power LED
#define UP_NUM 8 //definisce il numero di led della Up LED
#define ROUND_NUM 12 //definisce il numero di led della Round LED
#define VIR_NUM 8 //definisce il numero di led del Virus LED
CRGB leds1[ARM_NUM];
CRGB leds2[PWR_NUM];
CRGB leds3[UP_NUM];
CRGB leds4[DOWN_NUM];
CRGB leds5[ROUND_NUM];
CRGB leds6[VIR_NUM];
#define DELAY_TIME 125 // Define the delay time for the rotation effect
//Velocità Lampeggiamento LED
int SPEED1 = 25;
int SPEED2 = 50;
/*int SPEED3 = 100;
int SPEED4 = 300;
int SPEED5 = 400;*/
//IS VERY IMPORTANT THAT YOU TEST THIS TIME. BY DEFAULT IS IN 1 SEC. THAT IS NOT TOO MUCH. SO TEST IT!
const int Aux_TIME = 15000;
//Variabili del Timer
int GAMEHOURS = 0;
int GAMEMINUTES = 1;
int BOMBMINUTES = 1;
int ACTIVATESECONDS = 5;
int t = 80; //tempo di accensione dei LED
int x = 0 ; //conteggio ciclo
boolean sdStatus = false; //Game BOMB 1
boolean sd2Status = false; //Game BOMB 2
//boolean doStatus = false; //Game Conquer
boolean start = true;
boolean endGame = false;
boolean defuseando;
boolean cancelando;
// Setup Suoni e Sirena
boolean soundEnable = false; //Decide se abilitare/Disabilitare il Buzzer nel menu Config
boolean SirenaEnable = false; //Decide se abilitare/Disabilitare la Sirena nel menu Config
boolean RepeatEnable = false; //Funzione per abilitare il repeat se la sirena viene abilitata
int Sirena = 3; //Definisce il PIN per la Sirena
int Repeat = 1; //Definisce il PIN del Repeat button
int tonepin = 13; //Definisce il PIN per il Buzzer
//TONI DEL BUZZER
int tonoPitido = 3000;
int tonoAlarma1 = 700;
int tonoAlarma2 = 2600;
int tonoActivada = 1330;
int errorTone = 100;
unsigned long iTime;
unsigned long timeCalcVar;
unsigned long redTime;
unsigned long greenTime;
unsigned long iZoneTime;
byte team = 0;
void setup()
{
// SIRENA SPENTA ALL'ACCENSIONE
digitalWrite(Sirena, LOW);
digitalWrite(Repeat, LOW);
//NeopIxel Setup
FastLED.addLeds<WS2811, ARMLED, RGB>(leds1, ARM_NUM);
FastLED.addLeds<WS2811, PWRLED, RGB>(leds2, PWR_NUM);
FastLED.addLeds<WS2811, UPLED, RGB>(leds3, UP_NUM);
FastLED.addLeds<WS2811, DOWNLED, RGB>(leds4, DOWN_NUM);
FastLED.addLeds<WS2811, ROUNDLED, RGB>(leds5, ROUND_NUM);
FastLED.addLeds<WS2811, VIRUSLED, RGB>(leds6, VIR_NUM);
FastLED.clear();
// Accende LED Power
for (int i = 0; i < PWR_NUM; i++, 40)
{
leds2[i] = CRGB(255, 0, 0);
}
FastLED.show();
//LCD Setup
lcd.init();
lcd.backlight();
// Power Tone
tone(tonepin, 2400, 30);
delay(140);
tone(tonepin, 2400, 30);
delay(140);
tone(tonepin, 2400, 30);
delay(140);
//Power On Message
lcd.setCursor(0, 0);
lcd.print(" BOMBA AIRSOFT ");
lcd.setCursor(0, 1);
lcd.print(" BY CM-LABTECH ");
delay(2000);
cls();
lcd.setCursor(0, 0);
lcd.print(" VERSIONE ");
lcd.setCursor(0, 1);
lcd.print(" FIRMWARE 3.5.2 ");
delay(2000);
cls();
lcd.setCursor(0, 0);
lcd.print(" SOFTAIR - TEAM ");
lcd.setCursor(0, 1);
lcd.print("CONTRACTORS (NA)");
delay(1500);
//Keypad Setup
keypad.setHoldTime(50);
keypad.setDebounceTime(50);
keypad.addEventListener(keypadEvent);
delay(3000);
//Pin Mode Setup
pinMode(PWRLED, OUTPUT);
pinMode(ARMLED, OUTPUT);
pinMode(ROUNDLED, OUTPUT);
pinMode(UPLED, OUTPUT);
pinMode(DOWNLED, OUTPUT);
pinMode(VIRUSLED, OUTPUT);
pinMode(Sirena, OUTPUT);
pinMode(Repeat, OUTPUT);
//Graphics Elements Seup
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,
B11111,
B11111,
B00000,
B00000,
};
byte down[8] = {
B00000,
B00000,
B11111,
B11111,
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()
{
// TUTTI I LED ACCESI BLU ALL'ACCENSIONE
fixedLEDsBlue();
menuPrincipal();
}
Segnale PLAY
Verso PIN IO2
su Scheda Audio
Segnale REPEAT
Verso PIN IO4
su Scheda Audio
CANCEL/BACK
= Tasto C
SELECT/ARM/DISARM
= Tasto D
RIGHT DOWNLED
LEFT DOWNLED
VIRUS LED
ROUND
LED
UP LED
ARM LED
POWER LED
A = Sale sù nel Menu o seleziona se indicato
B= Scende giù nel Menu o seleziona se indicato
C= Calncella o torna alla voce precedente (=Pulsante Verde)
D= Seleziona o Attiva inserimento codice (=Pulsante Rosso)
BUZZER