Step One: Define the Purpose.
- First, write out the main purpose of the project idea. If it has multiple functions, decide which features are needed versus those that would be nice but aren’t necessary at first. See also, seller’s previous video about common Arduino mistakes. Keep it simple at first; users can always add to it later.
Step Two: Classify Inputs and Outputs.
- Next, classify the project’s inputs and outputs. A weather monitor might have a temperature and humidity sensor and a display of some kind. Internet projects might have a cloud service as an input, output, or both, like the seller’s Internet Valentine project which also has a button input and LED and vibrating motor outputs for each circuit. This project is a prop passkey evaluator that uses a membrane keypad input and outputs to an alphanumeric display as well as three indicator LEDs.
Step 3: Write Pseudocode.
- The next step is to write pseudocode that attempts to walk through the program’s main loop. Pseudocode is just plain words used to explain the program. It shouldn’t be overcomplicated but should sketch out the basic causes and effects the user wants to deal with in their program.
- Yellow LED starts on.
- Monitor and store input from membrane keypad.
- Use special * and # characters to start and stop entering the password.
- If the passcode is correct then complete the following:
- Turn on the green LED (light emitting diode).
- Display “OPEN” on display.
If the passcode is incorrect then complete the following:
- Turn on the red LED
- Display “NOPE” on display
Step Four: Test Hardware.
- Select and evaluate hardware components that could work for the user’s inputs and outputs.
- Build and run a sample for each component the user is working with. This involves downloading any relevant code libraries, and checking out example code that tests it is wired correctly. For inputs, the user will use the serial monitor to get some feedback.
- Add an alphanumeric display with an i2c backpack, and three different colored LEDs each with their own resistor. Upload the sample code for the display to verify it’s connected properly, then run a simple blink sketch to test the LEDs.
- It’s easier to discover that something is wired incorrectly at this stage, when the user is working with code that’s known to work with the component at hand rather than trying to debug wiring and code at the same time.
Step Five: Create The User’s New Program.
- Create a new sketch where you’ll paste in elements of all of the sample sketches to make the program.
- In the loop, if the user doesn’t have a good example to follow or want to write it from scratch, paste in your pseudocode as comments to start. Then the user can start to create the logical overall structure of the program.
- It’s possible one of the sample sketches already does most of its core structure, or to be easily able to find something online that does. It’s likely that another has done something similar to the user’s idea before, even if it uses different hardware. Look online and find a few membrane keypad door lock projects, all using this password library. Download them from the library and check out the examples that come with it. There is a membrane keypad passkey evaluator sample that does exactly what this project wants. All the user has to do is include my desired outputs, so code for the display and LEDs.
- One really good practice, while the user is doing this, is to compile their program often. That way, if there's an error, they'll be able to isolate them at the time they copied over such-and-such.
- Note: Here’s where it’s critical to pay attention to matching curly braces, missing semicolons, and other typos that would make the program hard to debug.
Step Six: Make Incremental Improvements.
- There will undoubtedly be unexpected issues that will come up once the user puts all the elements together and they actually see how it's working. They might change what they want their program to do. This is the nature of coding. They’ll want to keep track of their different iterations and be smart about how they name their files. This seller recommends using version numbers. When the user hits a milestone, name it version 2, then save a version 3 and start making new changes.
- After the user’s base project is working, then it’s cool to go ahead and add any other features from the user’s “nice to have” list or others that you brainstormed during the build.