// need to add flashing winning teams see red team standard mode
//need to adjust winning displays to be centered
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // Initialize the LCD
const int menuboutton = 4;
const int buttonred = 3;
const int buttonblue = 2;
const int buttongreen = 8;
const int redledPin = 7; // the number of the LED pin
const int greenledPin = 6; // the number of the LED pin
const int blueledPin = 5; // the number of the LED pin
const int speakerPin = 9;
int buttonStatered = 0; // variable for reading the pushbutton status
int buttonStategreen = 0; // variable for reading the pushbutton status
int buttonStateblue = 0; // variable for reading the pushbutton status
int bouttonmenu = 0;
int bouttonblue = 0;
int bouttonred = 0;
int bouttongreen = 0;
int dernier_etat_buttonStatered = LOW;
int dernier_etat_buttonStateblue = LOW;
int dernier_etat_buttonStategreen = LOW;
int temps_defini = 500; //defined time
int redsecond=00, redminute=5, redhour=0; // declare time variables
int redmillis = 0;
int greensecond=00, greenminute=5, greenhour=0; // declare time variables
int greenmillis = 0;
int bluesecond=00, blueminute=5, bluehour=0; // declare time variables
int bluemillis = 0;
int secondRAZGREEN=30, minuteRAZGREEN=0, hourRAZGREEN=0, millisRAZGREEN= 0; // declare time variables
int secondRAZRED=30, minuteRAZRED=0, hourRAZRED=0, millisRAZRED=0;
int secondRAZBLUE=30, minuteRAZBLUE=0, hourRAZBLUE=0, millisRAZBLUE=0;
int second=00, minute=05, hour=0;
int typejeu = 0;
int redmillis1 = 0;
int redsecond1 = 0;
int redminute1 = 0;
int redhour1 = 0;
int bluemillis1 = 0;
int bluesecond1 = 0;
int blueminute1 = 0;
int bluehour1 = 0;
boolean variable1 = false;
boolean variable2 = false;
boolean variable3 = false;
boolean ledStatered = false;
boolean ledStategreen = false;
boolean ledStateblue = false;
unsigned long Timeold=0;
unsigned long debut_buttonStatered;
unsigned long debut_buttonStateblue;
unsigned long debut_buttonStategreen;
static unsigned long lastTick = 0;
void setup() {
pinMode(menuboutton, INPUT);
pinMode(buttonred, INPUT);
pinMode(buttonblue, INPUT);
pinMode(buttongreen, INPUT);
pinMode(speakerPin, OUTPUT);
digitalWrite(redledPin, LOW);
digitalWrite(greenledPin, LOW);
digitalWrite(blueledPin, LOW);
buttonStatered = digitalRead(buttonred);
buttonStategreen = digitalRead(buttongreen);
buttonStateblue = digitalRead(buttonblue);
bouttonmenu = digitalRead(menuboutton);
lcd.begin(16, 2);
lcd.clear();
lcd.setCursor( 2, 0 );
lcd.print( "Airsoft Base" );
lcd.setCursor( 3, 1 );
lcd.print( "By Surfer" );
delay(4000);
lcd.clear();
lcd.setCursor( 2, 0 );
lcd.print("Mode Standard");
lcd.setCursor(2, 1);
lcd.print("Press Button");
}
void loop() {
suite();
}
void suite(){
buttonStatered = digitalRead(buttonred);
buttonStategreen = digitalRead(buttongreen);
buttonStateblue = digitalRead(buttonblue);
bouttonmenu = digitalRead(menuboutton);
if (bouttonmenu == HIGH) {
menu();
}
else if (typejeu == 1){
RAZ();
}
else if (typejeu == 2){
compteur();
}
else if (typejeu == 3){
time();
}
else if (typejeu == 4){
bouton();
}
else {
normal();
}
}
void menu(){
buttonStatered = digitalRead(buttonred);
buttonStategreen = digitalRead(buttongreen);
buttonStateblue = digitalRead(buttonblue);
bouttonmenu = digitalRead(menuboutton);
if (digitalRead(menuboutton) == HIGH) {
delay(500); //we avoid skipping the menus all at once
lcd.clear();
lcd.setCursor( 6, 0 );
lcd.print( "MENU" );
lcd.setCursor( 2, 1 );
lcd.print("Mode Standard");
Timeold=millis();
while(millis()-Timeold<=5000)// we exit the menu if no action for 5 seconds
{
if (digitalRead(buttonblue) == HIGH){
delay(300);
lcd.clear();
lcd.setCursor( 1, 0 );
lcd.print("Mode Standard");
lcd.setCursor(3, 1);
lcd.print("Started");
typejeu = 0;
delay(2000);
lcd.setCursor(0, 1);
lcd.print("Press Team Color");
normal();
}
if (digitalRead(menuboutton) == HIGH) {
delay(500); //we avoid skipping the menus all at once
lcd.clear();
lcd.setCursor( 6, 0 );
lcd.print( "MENU" );
lcd.setCursor( 0, 1 );
lcd.print("Mode with RESET");
Timeold=millis();
while(millis()-Timeold<=5000)// we exit the menu if no action for 5 seconds
{
if (digitalRead(buttonblue) == HIGH){
delay(500);
lcd.clear();
lcd.setCursor( 0, 0 );
lcd.print("Mode with RESET");
lcd.setCursor(3, 1);
lcd.print("Started");
delay(2000);
typejeu = 1;
lcd.setCursor(0, 1);
lcd.print("Press Team Color");
RAZ(); }
if (digitalRead(menuboutton) == HIGH) {
delay(500); //we avoid skipping the menus all at once
lcd.clear();
lcd.setCursor( 6, 0 );
lcd.print( "MENU" );
lcd.setCursor( 2, 1 );
lcd.print("Counter Mode");
Timeold=millis();
while(millis()-Timeold<=5000)// we exit the menu if no action for 5 seconds
{
if (digitalRead(buttonblue) == HIGH){
delay(500);
lcd.clear();
lcd.setCursor( 2, 0 );
lcd.print("Counter Mode");
lcd.setCursor(3, 1);
lcd.print("Started");
delay(2000);
typejeu = 2;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Press Team Color");
compteur(); }
if (digitalRead(menuboutton) == HIGH) {
delay(500); //we avoid skipping the menus all at once
lcd.clear();
lcd.setCursor( 6, 0 );
lcd.print( "MENU" );
lcd.setCursor( 2, 1 );
lcd.print("Time Setting");
Timeold=millis();
while(millis()-Timeold<=5000)// we exit the menu if no action for 5 seconds
{
if (digitalRead(buttonblue) == HIGH){
delay(500);
lcd.clear();
lcd.setCursor( 1, 0 );
lcd.print("Time Setting");
lcd.setCursor(0, 1);
lcd.print("R=sec+ G=0 B=mn+");
typejeu = 3;
delay(2000);
time(); }
if (digitalRead(menuboutton) == HIGH) {
delay(500); //we avoid skipping the menus all at once
lcd.clear();
lcd.setCursor( 6, 0 );
lcd.print( "MENU" );
lcd.setCursor( 1, 1 );
lcd.print("Adj. Button");
Timeold=millis();
while(millis()-Timeold<=5000)// on sort du menu si aucune action pendant 5 secondes
{
if (digitalRead(buttonblue) == HIGH){
delay(500);
lcd.clear();
lcd.setCursor( 1, 0 );
lcd.print("Adjustment Button");
lcd.setCursor(0, 1);
lcd.print(" R = + G = - ");
typejeu = 4;
delay(2000);
bouton(); }
if (digitalRead(menuboutton) == HIGH) {
delay(500);
menu();}
}
}
}
}
}
}
}
}
}
}
}
void bouton(){
/*lcd.setCursor(0, 1);
lcd.print(" ");
lcd.setCursor(6, 1);
lcd.print(temps_defini);*/
if (buttonStatered == HIGH) {
lcd.setCursor(0, 1);
lcd.print(" ");
delay (200);
temps_defini = temps_defini +1000 ;
lcd.setCursor(5, 1);
lcd.print(temps_defini/1000);
lcd.print(" Sec");
}
if (buttonStategreen == HIGH) {
lcd.setCursor(0, 1);
lcd.print(" ");
delay (200);
temps_defini = temps_defini -1000 ;
lcd.setCursor(5, 1);
lcd.print(temps_defini/1000);
lcd.print(" Sec");
}
}
void time(){
if (buttonStateblue == HIGH) {
lcd.setCursor(0, 1);
lcd.print(" ");
delay (200);
minute++;
lcd.setCursor(4, 1);
if (hour <=9) {
lcd.print("0");
}
lcd.print(redhour, DEC); // the hour, sent to the screen in decimal format
lcd.print(":"); // a colon between the hour and the minute
if (minute <=9) {
lcd.print("0");
}
lcd.print(minute, DEC); // the minute, sent to the screen in decimal format
lcd.print(":"); // a colon between the minute and the second
if (second <=9) {
lcd.print("0");
}
lcd.print(second, DEC); // the second, sent to the screen in decimal format
if (minute >= 59) {
if (minute = 59) {
hour++;
minute = 0;
}
}
}
if (buttonStatered == HIGH) {
lcd.setCursor(0, 1);
lcd.print(" ");
static unsigned long millis = 30;
millis++;
lcd.setCursor(4, 1);
if (hour <=9) {
lcd.print("0");
}
lcd.print(redhour, DEC); // the hour, sent to the screen in decimal format
lcd.print(":"); // a colon between the hour and the minute
if (minute <=9) {
lcd.print("0");
}
lcd.print(minute, DEC); // the minute, sent to the screen in decimal format
lcd.print(":"); // a colon between the minute and the second
if (second <=9) {
lcd.print("0");
}
lcd.print(second, DEC); // the second, sent to the screen in decimal format
if (millis >= 30) {
if (millis = 30){
second++;
millis = 0;
}
}
if (second >= 59) {
if (second = 59) {
minute++;
second = 0;
}
}
if (minute >= 59) {
if (minute = 59) {
hour++;
minute = 0;
}
}
}
if (buttonStategreen == HIGH) {
lcd.setCursor(0, 1);
lcd.print(" ");
static unsigned long millis = 30;
millis--;
lcd.setCursor(4, 1);
if (hour <=9) {
lcd.print("0");
}
lcd.print(hour, DEC); // the hour, sent to the screen in decimal format
lcd.print(":"); // a colon between the hour and the minute
if (minute <=9) {
lcd.print("0");
}
lcd.print(minute, DEC); // the minute, sent to the screen in decimal format
lcd.print(":"); // a colon between the minute and the second
if (second <=9) {
lcd.print("0");
}
lcd.print(second, DEC); // the second, sent to the screen in decimal format
if (millis >= 0) {
if (millis = 0){
second--;
millis = 30;
}
}
if (second >= 0) {
if (second = 0) {
minute--;
second = 59;
}
}
if (minute >= 0) {
if (minute = 0) {
hour--;
minute = 59;
}
}
}
bluesecond = second;
blueminute = minute;
bluehour = hour;
redsecond = second;
redminute = minute;
redhour = hour;
greensecond = second;
greenminute = minute;
greenhour = hour;
secondRAZRED = second;
minuteRAZRED = minute;
hourRAZRED = hour;
secondRAZGREEN = second;
minuteRAZGREEN = minute;
hourRAZGREEN = hour;
secondRAZBLUE = second;
minuteRAZBLUE = minute;
hourRAZBLUE = hour;
}
void normal(){
// if it is, the buttonStatered is HIGH:
while (buttonStatered == HIGH) {
buttonStatered = digitalRead(buttonred);
digitalWrite(redledPin, HIGH);
digitalWrite(greenledPin, LOW);
digitalWrite(blueledPin, LOW);
lcd.clear();
lcd.setCursor(7, 0);
lcd.print("RED");
ledStatered = true;
ledStategreen = false;
ledStateblue = false;
}
if (ledStatered == true){
if (redmillis > 0) {
redmillis--;
}
// decrement one second every 1000 milliseconds
if (redsecond > 0) {
if (millis() - lastTick >= 1000) {
lastTick = millis();
redsecond--;
redmillis = 9;
}
}
// decrement one minute every 60 seconds
if (redminute > 0) {
if (redsecond <= 0) {
redminute--;
redsecond = 59; // reset seconds to 59
}
}
// decrement one hour every 60 minutes
if (redhour > 0) {
if (redminute <= 0) {
redhour--;
redminute = 59; // reset minutes to 60
}//closes if
}//closes if
lcd.setCursor(4, 1);
if (redhour <=9) {
lcd.print("0");
}
lcd.print(redhour, DEC); // the hour, sent to the screen in decimal format
lcd.print(":"); // a colon between the hour and the minute
if (redminute <=9) {
lcd.print("0");
}
lcd.print(redminute, DEC); // the minute, sent to the screen in decimal format
lcd.print(":"); // a colon between the minute and the second
if (redsecond <=9) {
lcd.print("0");
}
lcd.print(redsecond, DEC); // the second, sent to the screen in decimal format
lcd.print(" ");
if (redsecond == 0 && redminute == 0 && redhour == 0) {
lcd.clear();
lcd.setCursor(3, 0);
lcd.print("RED TEAM");
lcd.setCursor(4, 1);
lcd.print("VICTORY");
digitalWrite(speakerPin, HIGH);//turn on buzzer
delay(3000);//wait 3 seconds
digitalWrite(speakerPin, LOW);//turn off buzzer
delay(3000);//wait 3 seconds
}
}
while (buttonStategreen == HIGH) {
// turn LED on:
digitalWrite(redledPin, LOW);
digitalWrite(greenledPin, HIGH);
digitalWrite(blueledPin, LOW);
lcd.clear();
lcd.setCursor(6, 0);
lcd.print("GREEN");
buttonStategreen = digitalRead(buttongreen);
ledStatered = false;
ledStategreen = true;
ledStateblue = false;
}
if (ledStategreen == true){
if (greenmillis > 0) {
greenmillis--;
}
// decrement one second
if (greensecond > 0) {
if (millis() - lastTick >= 1000) {
lastTick = millis();
greensecond--;
greenmillis = 9;
}
}
// decrement one minute every 60 seconds
if (greenminute > 0) {
if (greensecond <= 0) {
greenminute--;
greensecond = 59; // reset seconds to 60
}
}
// decrement one hour every 60 minutes
if (greenhour > 0) {
if (greenminute <= 0) {
greenhour--;
greenminute = 59; // reset minutes to 60
}//closes if
}//closes if
lcd.setCursor(4, 1);
if (greenhour <=9) {
lcd.print("0");
}
lcd.print(greenhour, DEC); // the hour, sent to the screen in decimal format
lcd.print(":"); // a colon between the hour and the minute
if (greenminute <=9) {
lcd.print("0");
}
lcd.print(greenminute, DEC); // the minute, sent to the screen in decimal format
lcd.print(":"); // a colon between the minute and the second
if (greensecond <=9) {
lcd.print("0");
}lcd.print(greensecond, DEC); // the second, sent to the screen in decimal format
lcd.print(" ");
if (greensecond == 0 && greenminute == 0 && greenhour == 0) {
lcd.clear();
lcd.setCursor(2, 0);
lcd.print("GREEN TEAM");
lcd.setCursor(4, 1);
lcd.print("VICTORY");
digitalWrite(speakerPin, HIGH);//turn on buzzer
delay(3000);//wait 3 seconds
digitalWrite(speakerPin, LOW);//turn off buzzer
delay(3000);//wait 3 seconds
}
}
while (buttonStateblue == HIGH) {
// turn LED on:
digitalWrite(redledPin, LOW);
digitalWrite(greenledPin, LOW);
digitalWrite(blueledPin, HIGH);
lcd.clear();
lcd.setCursor(6, 0);
lcd.print("BLUE");
buttonStateblue = digitalRead(buttonblue);
ledStatered = false;
ledStategreen = false;
ledStateblue = true;
}
if (ledStateblue == true){
if (bluemillis > 0) {
bluemillis--;
}
// decrement one second every 1000 milliseconds
if (bluesecond > 0) {
if (millis() - lastTick >= 1000) {
lastTick = millis();
bluesecond--;
bluemillis = 9;
}
}
// decrement one minute every 60 seconds
if (blueminute > 0) {
if (bluesecond <= 0) {
blueminute--;
bluesecond = 59; // reset seconds to 60
}
}
// decrement one hour every 60 minutes
if (bluehour > 0) {
if (blueminute <= 0) {
bluehour--;
blueminute = 59; // reset minutes to 60
}//closes if
}//closes if
lcd.setCursor(4, 1);
if (bluehour <=9) {
lcd.print("0");
}
lcd.print(bluehour, DEC); // the hour, sent to the screen in decimal format
lcd.print(":"); // a colon between the hour and the minute
if (blueminute <=9) {
lcd.print("0");
}
lcd.print(blueminute, DEC); // the minute, sent to the screen in decimal format
lcd.print(":"); // a colon between the minute and the second
if (bluesecond <=9) {
lcd.print("0");
}
lcd.print(bluesecond, DEC); // the second, sent to the screen in decimal format
if (bluesecond == 0 && blueminute == 0 && bluehour == 0) {
lcd.clear();
lcd.setCursor(3, 0);
lcd.print("BLUE TEAM");
lcd.setCursor(4, 1);
lcd.print("VICTORY");
digitalWrite(speakerPin, HIGH);//turn on buzzer
delay(3000);//wait 3 seconds
digitalWrite(speakerPin, LOW);//turn off buzzer
delay(3000);//wait 3 seconds
}
}
}
void RAZ(){
// if it is, the buttonStatered is HIGH:
while (buttonStatered == HIGH) {
buttonStatered = digitalRead(buttonred);
digitalWrite(redledPin, HIGH);
digitalWrite(greenledPin, LOW);
digitalWrite(blueledPin, LOW);
lcd.clear();
lcd.setCursor(7, 0);
lcd.print("RED");
ledStatered = true;
ledStategreen = false;
ledStateblue = false;
}
if (ledStatered == true){
secondRAZGREEN = second;
secondRAZBLUE = second;
minuteRAZGREEN = minute;
minuteRAZBLUE = minute;
hourRAZGREEN = hour;
hourRAZBLUE = hour;
// decrement one second every 1000 milliseconds
if (secondRAZRED > 0) {
if (millis() - lastTick >= 1000) {
lastTick = millis();
secondRAZRED--;
//millisRAZRED = 9;
}
}
// decrement one minute every 60 seconds
if (minuteRAZRED > 0) {
if (secondRAZRED <= 0) {
minuteRAZRED--;
secondRAZRED = 59; // reset seconds to 59
}
}
// decrement one hour every 60 minutes
if (hourRAZRED > 0) {
if (minuteRAZRED <= 0) {
hourRAZRED--;
minuteRAZRED = 59; // reset minutes to 60
}//closes if
}//closes if
lcd.setCursor(4, 1);
if (hourRAZRED <=9) {
lcd.print("0");
}
lcd.print(hourRAZRED, DEC); // the hour, sent to the screen in decimal format
lcd.print(":"); // a colon between the hour and the minute
if (minuteRAZRED <=9) {
lcd.print("0");
}
lcd.print(minuteRAZRED, DEC); // the minute, sent to the screen in decimal format
lcd.print(":"); // a colon between the minute and the second
if (secondRAZRED <=9) {
lcd.print("0");
}
lcd.print(secondRAZRED, DEC); // the second, sent to the screen in decimal format
if (secondRAZRED == 0 && minuteRAZRED == 0 && hourRAZRED == 0) {
lcd.clear();
lcd.setCursor(3, 0);
lcd.print("RED TEAM");
lcd.setCursor(4, 1);
lcd.print("VICTORY");
digitalWrite(speakerPin, HIGH);//turn on buzzer
delay(3000);//wait 3 seconds
digitalWrite(speakerPin, LOW);//turn off buzzer
delay(3000);//wait 3 seconds
}
}
while (buttonStategreen == HIGH) {
// turn LED on:
digitalWrite(redledPin, LOW);
digitalWrite(greenledPin, HIGH);
digitalWrite(blueledPin, LOW);
lcd.clear();
lcd.setCursor(6, 0);
lcd.print("GREEN");
buttonStategreen = digitalRead(buttongreen);
ledStatered = false;
ledStategreen = true;
ledStateblue = false;
}
if (ledStategreen == true){
secondRAZRED = second;
secondRAZBLUE = second;
minuteRAZRED = minute;
minuteRAZBLUE = minute;
hourRAZRED = hour;
hourRAZBLUE = hour;
// decrement one second every 1000 milliseconds
if (secondRAZGREEN > 0) {
if (millis() - lastTick >= 1000) {
lastTick = millis();
secondRAZGREEN--;
//millisRAZGREEN = 9;
}
}
// decrement one minute every 60 seconds
if (minuteRAZGREEN > 0) {
if (secondRAZGREEN <= 0) {
minuteRAZGREEN--;
secondRAZGREEN = 59; // reset seconds to 59
}
}
// decrement one hour every 60 minutes
if (hourRAZGREEN > 0) {
if (minuteRAZGREEN <= 0) {
hourRAZGREEN--;
minuteRAZGREEN = 59; // reset minutes to 60
}//closes if
}//closes if
lcd.setCursor(4, 1);
if (hourRAZGREEN <=9) {
lcd.print("0");
}
lcd.print(hourRAZGREEN, DEC); // the hour, sent to the screen in decimal format
lcd.print(":"); // a colon between the hour and the minute
if (minuteRAZGREEN <=9) {
lcd.print("0");
}
lcd.print(minuteRAZGREEN, DEC); // the minute, sent to the screen in decimal format
lcd.print(":"); // a colon between the minute and the second
if (secondRAZGREEN <=9) {
lcd.print("0");
}
lcd.print(secondRAZGREEN, DEC); // the second, sent to the screen in decimal format
if (secondRAZGREEN == 0 && minuteRAZGREEN == 0 && hourRAZGREEN == 0) {
lcd.clear();
lcd.setCursor(2, 0);
lcd.print("GREEN TEAM");
lcd.setCursor(4, 1);
lcd.print("VICTORY");
digitalWrite(speakerPin, HIGH);//turn on buzzer
delay(3000);//wait 3 seconds
digitalWrite(speakerPin, LOW);//turn off buzzer
delay(3000);//wait 3 seconds
}
}
while (buttonStateblue == HIGH) {
// turn LED on:
digitalWrite(redledPin, LOW);
digitalWrite(greenledPin, LOW);
digitalWrite(blueledPin, HIGH);
lcd.clear();
lcd.setCursor(6, 0);
lcd.print("BLUE");
buttonStateblue = digitalRead(buttonblue);
ledStatered = false;
ledStategreen = false;
ledStateblue = true;
}
if (ledStateblue == true){
secondRAZRED = second;
secondRAZGREEN = second;
minuteRAZRED = minute;
minuteRAZGREEN = minute;
hourRAZRED = hour;
hourRAZGREEN = hour;
// decrement one second every 1000 milliseconds
if (secondRAZBLUE > 0) {
if (millis() - lastTick >= 1000) {
lastTick = millis();
secondRAZBLUE--;
}
}
// decrement one minute every 60 seconds
if (minuteRAZBLUE > 0) {
if (secondRAZBLUE <= 0) {
minuteRAZBLUE--;
secondRAZBLUE = 59; // reset seconds to 59
}
}
// decrement one hour every 60 minutes
if (hourRAZBLUE > 0) {
if (minuteRAZBLUE <= 0) {
hourRAZBLUE--;
minuteRAZBLUE = 59; // reset minutes to 60
}//closes if
}//closes if
lcd.setCursor(4, 1);
if (hourRAZBLUE <=9) {
lcd.print("0");
}
lcd.print(hourRAZBLUE, DEC); // the hour, sent to the screen in decimal format
lcd.print(":"); // a colon between the hour and the minute
if (minuteRAZBLUE <=9) {
lcd.print("0");
}
lcd.print(minuteRAZBLUE, DEC); // the minute, sent to the screen in decimal format
lcd.print(":"); // a colon between the minute and the second
if (secondRAZBLUE <=9) {
lcd.print("0");
}
lcd.print(secondRAZBLUE, DEC); // the second, sent to the screen in decimal format
if (secondRAZBLUE == 0 && minuteRAZBLUE == 0 && hourRAZBLUE == 0) {
lcd.clear();
lcd.setCursor(3, 0);
lcd.print("BLUE TEAM");
lcd.setCursor(4, 1);
lcd.print("VICTORY");
digitalWrite(speakerPin, HIGH);//turn on buzzer
delay(3000);//wait 3 seconds
digitalWrite(speakerPin, LOW);//turn off buzzer
delay(3000);//wait 3 seconds
}
}
}
void compteur(){
buttonStatered = digitalRead(buttonred);
buttonStateblue = digitalRead(buttonblue);
buttonStategreen = digitalRead(buttongreen);
if (buttonStatered == HIGH && dernier_etat_buttonStatered == LOW)
{
debut_buttonStatered = millis();
digitalWrite(redledPin, HIGH);
digitalWrite(greenledPin, LOW);
digitalWrite(blueledPin, LOW);
ledStatered = false;
ledStategreen = false;
ledStateblue = false;
variable1 = true;
variable2 = false;
variable3 = false;
}
if ( variable1 == true && buttonStatered == HIGH && dernier_etat_buttonStatered == HIGH){
if ((millis() - debut_buttonStatered) >= temps_defini){
//lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" ");
lcd.setCursor(0, 0);
lcd.print("RED / BLUE");
ledStatered = true;
}
}
if (ledStatered == true){
redmillis1++;
lcd.setCursor(0, 1);
lcd.print(redhour1, DEC);
lcd.print(":");
if (redminute1 <=9) {
lcd.print("0");
}
lcd.print(redminute1, DEC);
lcd.print(":");
if (redsecond1 <=9) {
lcd.print("0");
}
lcd.print(redsecond1, DEC);
lcd.print(" ");
if (redmillis1 >= 300) {
if (redmillis1 = 300) {
redsecond1++;
redmillis1 = 0;
}
}
if (redsecond1 >= 59) {
if (redsecond1 = 59) {
redminute1++;
redsecond1 = 0;
}
}
if (redminute1 >= 59) {
if (redminute1 = 59) {
redhour1++;
redminute1 = 0;
}
}
}
dernier_etat_buttonStatered = buttonStatered;
if (buttonStateblue == HIGH && dernier_etat_buttonStateblue == LOW)
{
debut_buttonStateblue = millis();
digitalWrite(redledPin, LOW);
digitalWrite(greenledPin, LOW);
digitalWrite(blueledPin, HIGH);
ledStatered = false;
ledStategreen = false;
ledStateblue = false;
variable1 = false;
variable2 = true;
variable3 = false;
}
if ( variable2 == true && buttonStateblue == HIGH && dernier_etat_buttonStateblue == HIGH){
if ((millis() - debut_buttonStateblue) >= temps_defini){
//lcd.clear(); // rem this ?
lcd.setCursor(0, 0);
lcd.print(" ");
lcd.setCursor(0, 0);
lcd.print("RED / BLUE");
ledStateblue = true;
}
}
if (ledStateblue == true){
bluemillis1++;
lcd.setCursor(9, 1);
lcd.print(bluehour1, DEC);
lcd.print(":");
if (blueminute1 <=9) {
lcd.print("0");
}
lcd.print(blueminute1, DEC);
lcd.print(":");
if (bluesecond1 <=9) {
lcd.print("0");
}
lcd.print(bluesecond1, DEC);
lcd.print(" ");
if (bluemillis1 >= 300) {
if (bluemillis1 = 300) {
bluesecond1++;
bluemillis1 = 0;
}
}
if (bluesecond1 >= 59) {
if (bluesecond1 = 59) {
blueminute1++;
bluesecond1= 0;
}
}
if (blueminute1 >= 60) {
if (blueminute1 = 60) {
bluehour1++;
blueminute1 = 0;
}
}
}
dernier_etat_buttonStateblue = buttonStateblue;
if (buttonStategreen == HIGH && dernier_etat_buttonStategreen == LOW)
{
debut_buttonStategreen = millis();
digitalWrite(redledPin, LOW);
digitalWrite(greenledPin, HIGH);
digitalWrite(blueledPin, LOW);
ledStatered = false;
ledStategreen = false;
ledStateblue = false;
variable1 = false;
variable2 = false;
variable3 = true;
}
if ( variable3 == true && buttonStategreen == HIGH && dernier_etat_buttonStategreen == HIGH){
if ((millis() - debut_buttonStategreen) >= temps_defini){
lcd.clear();
lcd.setCursor(2, 0);
lcd.print("TIME RESET!!");
ledStategreen = true;
}
}
if (ledStategreen == true){
redmillis1 = 0;
redsecond1 = 0;
redminute1 = 0;
redhour1 = 0;
bluemillis1 = 0;
bluesecond1 = 0;
blueminute1 = 0;
bluehour1 = 0;
}
dernier_etat_buttonStategreen = buttonStategreen;
}