Ciao a tutti ho creato questo programmino (è ancora in attesa di migliorie)
#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7, 8);
char password[5] = {95,95,95,95};
char Pcorretta[5] = {"1992"};
char tasti[5][5] = {
{"1", "2", "3", "A"},
{"4", "5", "6", "B"},
{"7", "8", "9", "C"},
{"*", "0", "#", "D"}
};
char tastoPremuto1;
char tastoPremuto2;
int latchPin = 12;
int clockPin = 13;
int dataPin = 11;
long oldTime;
int lockCr;
boolean Blink = HIGH;
boolean risposta = 0;
byte chiave1 [8] = {14,17,17,17,17,17,14};
byte chiave2 [8] = {0,0,0,31,2,2,0};
void setup()
{
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(14, INPUT);
pinMode(15, INPUT);
pinMode(16, INPUT);
pinMode(17, INPUT);
lcd.createChar(1, chiave1);
lcd.createChar(2, chiave2);
lcd.begin(7, 2);
lcd.noCursor();
Serial.begin(9600);
//
oldTime = 650;
lcd.home();
lcd.print("PASSWORD");
Blink = 1;
}
void loop()
{
while(1)
{
for(int cr=0; cr<4; cr++)
{
if ((Blink == LOW) && (password[cr] == 95)){
password[cr] = 32;
}
if ((Blink == HIGH) && (password[cr] == 32)){
password[cr] = 95;
}
lcd.setCursor((cr+4), 1);
lcd.write(password[cr]);
}
if (oldTime < millis())
{
Blink = !Blink;
oldTime = (millis() + 650);
}
if (lockCr == 4){
break;
}
leggoKeyboar();
}
delay(1000);
lcd.clear();
for(int i=0; i<48; i++)
{
if(password[i]!=Pcorretta[i])
{
risposta=1;
break;
}
else
{
risposta=0;
}
}
Serial.println(risposta);
if(risposta == 0)
{
lcd.clear();
lcd.home();
lcd.print("UNLOCKED");
lcd.setCursor(6, 1);
lcd.write(1);
lcd.setCursor(7, 1);
lcd.write(2);
delay(5000);
while(1){
}
}else{
lcd.clear();
lcd.home();
lcd.print("ERROR");
for(int j=0; j<9; j++)
{
lcd.setCursor(6, 1);
lcd.write(1);
lcd.setCursor(7, 1);
lcd.write(2);
delay(400);
lcd.setCursor(6, 1);
lcd.write(120);
lcd.setCursor(7, 1);
lcd.write(120);
delay(400);
}
oldTime = 650; //reset
lcd.clear();
lcd.home();
lcd.print("PASSWORD");
Blink = 1;
lockCr=0;
for(int i=0; i<5; i++)
{
password[i] = 95;
}
}
}
void leggoKeyboar()
{
for (int k=0, k<4, k++)
{
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, (B00000001 << k));
digitalWrite(latchPin, HIGH);
for (int l=0, l<4, l++)
{
if (digitalRead(l+14) != 0)
{
tastoPremuto1 = tasti[l][k];
break;
}else{
tastoPremuto1 = 0;
}
}
}
delay(30);
for (int k=0, k<4, k++)
{
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, (B00000001 << k));
digitalWrite(latchPin, HIGH);
for (int l=0, l<4, l++)
{
if (digitalRead(l+14) != 0)
{
tastoPremuto2 = tasti[l][k];
break;
}else{
tastoPremuto2 = 0;
}
}
}
if(tastoPremuto1 == tastoPremuto2) && (tastoPremuto1 != 0)
{
while(tastoPremuto1 == tastoPremuto2)
{
for (int k=0, k<4, k++)
{
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, (B00000001 << k));
digitalWrite(latchPin, HIGH);
for (int l=0, l<4, l++)
{
if (digitalRead(l+14) != 0)
{
tastoPremuto2 = tasti[l][k];
break;
}else{
tastoPremuto2 = 0;
}
}
}
}
password[lockCr] = tastoPremuto1;
lockCr++;
}
}
l'ho controllato e ricontrollato ma non mi sembra ci siano errori eppure l'IDE mi da i seguenti errori
password_lcd:11: error: too many initializers for 'char [5]'
password_lcd:11: error: too many initializers for 'char [5]'
password_lcd:11: error: too many initializers for 'char [5]'
password_lcd:11: error: too many initializers for 'char [5]'
password_lcd.ino: In function 'void leggoKeyboar()':
password_lcd:134: error: expected initializer before '<' token
password_lcd:191: error: expected primary-expression at end of input
password_lcd:191: error: expected `;' at end of input
password_lcd:191: error: expected primary-expression at end of input
password_lcd:191: error: expected `)' at end of input
password_lcd:191: error: expected statement at end of input
password_lcd:191: error: expected `}' at end of input
mi riuscireste ad aiutare a capire di che si tratta perchè io non riesco a far coincidere gli errori riportati con ciò che c'è scritto nello Sketch