A lot of changes and troubleshooting had to be done to my original code. The first challenge I had was during the designing stage. I could not use the tinkercad LCD because it would have taken up too many digital ports on the Arduino, not leaving enough for the keypad to connect to the Arduino. I solved this by using a sunfounder LCD. This means I only had to use four ports (two analogs, one ground and one power). This freed up ports 2-9 to use for the keypad. Another major issue I had was getting the placement of the numbers. My original code only used one line, but instead of having it say “Enter a password” I wanted it to ask a riddle, and have the password be the answer to the riddle. Because the riddle took up two lines, I had to change the placement of the numbers that displayed as you typed them. The problem was that the lcd.setCursor was using the variable data_count and not a value on the lcd itself and was inside the loop. This made it difficult to move the starting position of the loop to somewhere in the middle of the lcd. I tried to fix this by having the top line of the lcd scroll horizontally and the bottom stay static, but Arduino does not have this option built in to the code meaning it would have to be done through its own custom for loop. I decided against this because it would make my code harder to read and more complicated unnecessarily. My solution was that I had each new number replace the one before it on the same position on the lcd, as opposed to the loop that incremented by one each time and moved the cursor one over each time a button was pressed. This new design made my code simpler and easier to follow, and didn’t sacrifice any functionality. Some things that went well was the first part of my code. I had to learn how to use the keypad library, how to set it up and configure it by giving each button a value. This part was a very smooth learning. There are many real work applications using this concept. This same concept could be used with variations to unlock doors or panels by changing what happens when the correct answer from displaying “correct” to turning a motor that will move a lock, or by sending an analog signal to an external device. In the real world, one team would be dedicated to the coding (programmers), one for designing the build (designers/engineers), and one for building it (engineers).
Logic diagram of the code