Need help with variable keypad entries.

Good afternoon all,

I’m currently stuck on my project and I’m looking to see if anyone can help.

My Arduino Experience
I have started using Arduino about a month ago with no experience prior to this. I have tried to write my code in a format that can be read and understood as if I was to open it a week later etc. My coding may not be the most efficient way of producing what I want but it is how I have learnt to do it so far. Basically I have been copying and pasting code and then removing bits of code one part at a time to try and understand what each part does.

The project
For personal educational use I am looking to create a small Arduino warehouse. The idea is that a user inputs a product id, bin number id, and quantity id with a keypad, which displays the keys pressed on screen and when the key amount matches the input_Length and specific INPUT DATA, it executes what needs to be done for each INPUT DATA.

At the moment the user can input all the data types successfully but they must be of the same length and all unique;

I am looking to be able to allow the user to input a variable amount of keypad entries and submit the entries using a specific keypad button, ideally ‘#’
for example;
product id “5000111” #
bin number “AAAA” #
Quantity “32” #

I hope I have explained this enough and I hope someone may be able to help.

Kind regards

my code so far is attached…

HELP CODE.txt (23.6 KB)

I would start by stripping down all the other code and write a simple sketch that terminates the input when a user presses '#'. Get that working and then incorporate it into your larger project.

As for your project, you could benefit from adding some consistency throughout the code, even when cutting and pasting from elsewhere.

  • Keep a consistent variable naming convention - typical is it 'variableWithWordsCapitalized' which makes it easy to read.

  • keep consistent with your braces - either on the next line or not.

  • don't stack multiple lines onto the same line.

  • You have to calls to lcd.begin() - only need one inside setup(). You also have multiple places throughout your code where you set the cursor to line 2. You only have lines 0 and 1 on your display so these need to be fixed.

  • Abandon the 'String' class variables. Learn how to use regualr C-strings (char arrays with nul terminator). It will serve you well since String can lead to memory fragmentation and problems with the limited amount on Arduinos.

Thank you for getting back to me. I was reluctant to posting the code online just incase it was awful. It probably is. However your structural criticism is highly appreciated and I thank you very much for your time.

Your case is similar to the password input. See this Keypad - Password code