This isn't really a password is it? I'd throw the password library out.
Yes you are right but that's how much brain I got. Do you have another way of using a keypad to actually get something useful and use it to do what I talked about. If not I hope that You can just help fix what I have right now and after the project I will work on it myself to improve it.
I was looking what's available online. How to use a keypad and I mostly found how to use for a password, so I used it to do two things but now they want in between in increment of 20 so I have to do 10 setting.
And I just can go back and look for other solutions. especially I am new to this things.
Thanks anyway for your feedbacks
Here's what I am talking about:
#include <Keypad.h>
const byte IOXpin = 2;
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] =
{
{ '1','2','3' },
{ '4','5','6' },
{ '7','8','9' },
{ '*','0','#' }
};
byte rowPins [ROWS] = { 5, 4, 3, 12}; //connect to the row pinouts of the keypad
byte colPins [COLS] = { 8, 7, 6 }; //connect to the column pinouts of the keypad
// Create the Keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup()
{
pinMode(IOXpin, OUTPUT);
Serial.begin (9600);
} // end of setup
void processNumber (const unsigned long amount)
{
Serial.print ("Dispensing ");
Serial.print (amount);
Serial.println (" ml.");
// Sanity Claus
if (amount < 5 || amount > 500)
{
Serial.println ("Invalid amount ... aborting.");
return;
}
unsigned long startTime = millis ();
unsigned long runTime = amount * 100; // assume 0.1 secs per ml
digitalWrite (IOXpin, LOW);
while (millis () - startTime < runTime)
{
if (kpd.getKey() == '*') // cancel button
{
Serial.println ("Cancelled.");
break;
} // end of if cancelled
} // end of waiting for time to be up
digitalWrite (IOXpin, HIGH);
Serial.println ("Done.");
} // end of processNumber
void handleKeypress (const char key)
{
Serial.print ("Got: ");
Serial.println (key);
static unsigned long receivedNumber = 0;
switch (key)
{
case '#':
processNumber (receivedNumber);
receivedNumber = 0;
break;
case '0' ... '9':
receivedNumber *= 10;
receivedNumber += key - '0';
break;
default:
Serial.println ("Unexpected input!");
break;
} // end of switch
} // end of handleKeypress
void loop()
{
byte key = kpd.getKey();
if (key)
handleKeypress (key);
}
Don't need passwords. Just a simple keypad handler. Send the keys off to a state machine. That handles numbers. Then the "#" "commits" the number and it starts dispensing. You use the "*" to abort.
Now this might not do everything you want, but it shows the general idea.
Merci beaucoup mon ami pour votre aid. I don't know how to thank you. I am new to this and you just saved me the headache. I am trying to learn but given the time I have left and what I still have to do. I realized it's not worth it to spend more time to think about what each function does in the code. But Arduino is definitley fascinating. I need to look into it.
Thank you very much.