Rieccomi a chiedere aiuto.
In questi giorni ho modificato un po il codice, girando per la rete ho trovato pezzi di codice che mi servivano per il progetto li ho incollati ma giustamente non funziona nulla (però lo sketch non ha errori)
sono riuscito anche a collegare una tastiera 4x4 e a farla funzionare
non sto riuscendo però a richiamare i 2 void che dovrebbero fare settare la password e il countdown,come posso richiamarli nella void setup?
vi riporto il codice aggiornato all'ultima modifica
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
unsigned long myOldTime;
unsigned long pausa = 5000;
int timeLength = 0;
int passLength = 0;
String mostra = " ";
String password = "cccc";
String time = " ";
boolean getted = true;
char last = 'p';
boolean timeGetted = false;
int residuo = 0;
boolean passGetted = false;
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] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {9, 8, 7, 6}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display
void Countdown() {
if (timeLength < 5) { //attendo l'inserimento di 4 numeri
mostra = time;
if (!getted) {
if (last == 'c') { //se viene premuto C, cancello tutto e ricomincio
time = "____";
timeLength = 0;
getted = true;
} else {
if (timeLength < 4) { //finchè non ho 4 numeri non accetto la conferma
if ((last != '*') && (last != '#') && (last != 'a') && (last != 'b') && (last != 'd')) { //accetto solo numeri e li salvo, se è il 3 alora solo inferiori a 6
time.setCharAt(timeLength, last);
//Serial.println(time);
timeLength++;
getted = true;
} else {
getted = true;
}
} else { //ho gia 4 numeri
if (last == 'a') { //se ricevo la conferma proseguo
getted = true;
timeLength++;
timeGetted = true;
//Serial.println(time);
// residuo = timeToInt(time);
}
else {
getted = true;
}
}
}
}
}
}
void Password() {
if (passLength < 5) { //attendo l'inserimento di 4 numeri
mostra = password;
if (!getted) {
if (last == 'c') { //se viene premuto C, cancello tutto e ricomincio
password = "cccc";
passLength = 0;
getted = true;
} else {
if (passLength < 4) { //finchè non ho 4 numeri non accetto la conferma
if ((last != '*') && (last != '#') && (last != 'a') && (last != 'b') && (last != 'd')) { //accetto solo numeri e li salvo
password.setCharAt(passLength, last);
passLength++;
getted = true;
} else {
getted = true;
}
} else { //ho gia 4 numeri
if (last == 'A') { //se ricevo la conferma proseguo
getted = true;
passLength++;
passGetted = true;
//Serial.println(password);
}
else {
getted = true;
}
}
}
} else {
delay(5);
}
}
}
void setup()
{
lcd.init(); // initialize the lcd
// Print a message to the LCD.
Serial.begin(9600);
lcd.backlight(); //noBlacklight per oscurare schermo
lcd.setCursor(4, 0);
lcd.print("S.M.A.S.");
lcd.setCursor(3, 1);
lcd.print("La Bombaaa!");
delay(5000);
lcd.clear();
}
void loop()
{
}