Salve, mi sono scaricato questa libreria qui e ho provato a farla funzionare ma non mi riporta. Il codice è il seguente:
#include <OnewireKeypad.h>
#include <Password.h>
#define Rows 4
#define Cols 3
#define Pin A0
#define Row_Res 4700
#define Col_Res 1000
#define LEDVERDE 13
#define LEDROSSO 10
char KEYS[]= {
'1','2','3',
'4','5','6',
'7','8','9',
'*','0','#'
};
OnewireKeypad <Print, 12> KeyPad(Serial, KEYS, Rows, Cols, Pin, Row_Res, Col_Res );
Password password = Password( "4053" );
void setup ()
{
Serial.begin(115200);
pinMode(LEDVERDE,OUTPUT);
pinMode(LEDROSSO,OUTPUT);
KeyPad.SetHoldTime(1000);
KeyPad.ShowRange();
}
void loop()
{
char Key;
byte KState = KeyPad.Key_State();
if (KState == PRESSED)
{
if ( Key = KeyPad.Getkey() )
{
Serial << "Pressed: " << Key << "\n";
switch (Key)
{
case '*': checkPassword(); break;
case '#': password.reset(); break;
default: password.append(Key);
}
}
}
else if (KState == HELD)
{
Serial << "Key:" << KeyPad.Getkey() << " being held\n";
}
}
void checkPassword()
{
if (password.evaluate())
{
Serial.println("Success");
digitalWrite(LEDVERDE,HIGH);
}
else
{
Serial.println("Wrong");
digitalWrite(LEDROSSO,HIGH);
}
}
Arduino dovrebbe funzionare leggendo il pulsante attraverso un ingresso in analogico, e se la password è esatta dovrebbe accendersi il led verde, altrimenti il rosso, il tutto con la libreria OneWireKeypad. Sono costretto ad usare quella poichè mi servono altri 6 pin per l'rfid. Dove sbaglio?
Grazie in anticipo per l'aiuto.