hello
bon je viens de tester ton code, il fonctionne
je suis allé le récupérer sur la source.
chez moi le lcd est en 0x27
si ton scan te dit une autre adresse, mets la à la place de 0x27
c'est la 4ème ligne du code
LiquidCrystal_I2C lcd(0x27, 16, 2);
/*
Air Hockey da tavolo
Questo progetto è di libero utilizzo, basta che venga citato il programmat_Heures.
Programmat_Heures Firmware: Tartaglia daniele
sito: www.labdomotic.com
email: edstarink@fastwebnet.it
Youtube channel: https://www.youtube.com/channel/UCwMjr5HocO6S363x_-jzsmA
Facebook: https://www.facebook.com/daniele.tartaglia.73?ref=bookmarks
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <EEPROM.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // se non dovesse funzionare il display utilizza questo indirizzo:(0x27) al posto di (0x3F)
unsigned long previousMillis1 = 0;
unsigned long interval1 = 1000; //intervallo in (millisecondsi)
unsigned int counter = 0;
int timeRST = 0;
int _Heures = 45;
int _Minutes = 5;
int _Secondes = 6;
int buzzer = 49;
int Relais = 48;
int _Total_secondes = 0;
int reset = 0;
int start = A6;
int Score_1 = 0;
int Score_2 = 0;
int Joueur_1 = 2;
int Joueur_2 = 3;
int BP_Start = 5;
void setup() {
// put your setup code here, to run once:
lcd.begin();
// PORTA A PULL UP I PIN DIGITALI IN INGRESSO
pinMode(Joueur_1, INPUT_PULLUP);
pinMode(Joueur_2, INPUT_PULLUP);
pinMode(BP_Start, INPUT_PULLUP);
// ASSEGNA I PIN OUT DEI RELè E DEL BUZZER
pinMode(Relais, OUTPUT);
pinMode (buzzer, OUTPUT);
// PORTA FORZATAMENTE A LIVELLO ALTO IL RELè (PER ACCENDERLO DOVRAI PORTARLO A LIVELLO BASSO "LOW")
digitalWrite(Relais, HIGH);
// Introduzione prima della partenza
lcd.setCursor(0, 0);
lcd.print("Hockey sur table");
lcd.setCursor(0, 1);
lcd.print("par D. Tartaglia");
delay(2000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("P1= ");
lcd.setCursor(4, 0);
lcd.print(Score_1);
lcd.setCursor(7, 0);
lcd.print("/ P2= ");
lcd.setCursor(14, 0);
lcd.print(Score_2);
lcd.setCursor(0, 1);
lcd.print("Appuyez sur START");
}
void loop() {
/* *************************************************************************************
PREMI START E INIZIA IL GIOCO
*************************************************************************************
*/
int START = digitalRead(BP_Start);
if (START == LOW) {
_Total_secondes = 29;
Score_1 = 0;
Score_2 = 0;
}
while (_Total_secondes > 0)
{
digitalWrite(Relais, LOW); // ACCENDI IL Relais' APPENA COMINCIA IL GIOCO
//---------------------------------------------------------
/* *************************************************************************************
CONTAT_Heures PER RESETTARE IL GIOCO PRIMA DELLO SCADERE DEL TEMPO - MANTENIMENTO TEMPO 3 SEC CIRCA
*************************************************************************************
*/
int START = digitalRead(BP_Start);
if (START == LOW) {
timeRST++;
delay(10);
}
else
{
timeRST = 0;
}
/* *************************************************************************************
TEMPO MANTENIMENTO DEI 3 _Secondes RAGGIUNTO...RESETTA IL GIOCO
*************************************************************************************
*/
if (timeRST >= 50) {
_Total_secondes = 0;
lcd.clear();
lcd.print(" remise a zero ");
digitalWrite(Relais, HIGH);
timeRST = 0;
delay(1000);
lcd.clear();
delay(500);
lcd.setCursor(0, 0);
lcd.print("P1= ");
lcd.setCursor(4, 0);
lcd.print(Score_1);
lcd.setCursor(7, 0);
lcd.print("/ P2= ");
lcd.setCursor(14, 0);
lcd.print(Score_2);
lcd.setCursor(0, 1);
lcd.print("Appuyez sur START");
//lcd.print("Premi START");
delay(200);
break;
}
//---------------------------------------------------------
if (millis() - previousMillis1 > interval1) {
previousMillis1 = millis(); //save the last time I blinked the LED
_Total_secondes--;
_Heures = ((_Total_secondes / 60) / 60); // converte i _Secondes totali in _Heures
_Minutes = (_Total_secondes / 60) % 60; // converte i _Secondes totali in _Minutes
_Secondes = _Total_secondes % 60; // converte i _Secondes totali in _Secondes
lcd.setCursor(0, 1);
lcd.print("Tempo res: ");
if (_Minutes < 10) lcd.print("0");
lcd.print(_Minutes);
lcd.print(":");
if (_Secondes < 10) lcd.print("0");
lcd.print(_Secondes);
/* *************************************************************************************
TEMPO GIOCO FINITO, RESETTA GIOCO
*************************************************************************************
*/
if (_Total_secondes == 0)
{
digitalWrite(Relais, HIGH);
break;
}
}
lcd.setCursor(0, 0);
lcd.print("P1= ");
lcd.setCursor(4, 0);
lcd.print(Score_1);
lcd.setCursor(7, 0);
lcd.print("/ P2= ");
lcd.setCursor(14, 0);
lcd.print(Score_2);
/* *************************************************************************************
PULSANTE INCREMENTO +1 DEL CONTAT_Heures GIOCAT_Heures 1
*************************************************************************************
*/
int compteur_temps_1 = digitalRead(Joueur_1);
if (compteur_temps_1 == LOW) {
delay(120);
Score_1++;
tone(buzzer, 1000); // Send 1KHz sound signal...
delay(200);
noTone(buzzer);
}
/* *************************************************************************************
PULSANTE INCREMENTO +1 DEL CONTAT_Heures GIOCAT_Heures 2
*************************************************************************************
*/
int compteur_temps_2 = digitalRead(Joueur_2);
if (compteur_temps_2 == LOW) {
delay(120);
Score_2++;
tone(buzzer, 1000); // Send 1KHz sound signal...
delay(200);
noTone(buzzer);
}
}
}