Building a CLI
In this section, we are going to parse the input from a user and compare the input with predefined commands. These commands will then be executed by the microcontroller. For this project, we are going to use the same hardware setup that we used in the previous one.
We will start by creating a new folder named hd44780-cli
inside the Chapter06
folder. Then, we must create a main.go
file with an empty main
function inside it. The project's structure should now look similar to the following:
Now that the project structure has been set up, we can implement the logic. To do so, follow these steps:
- Above the
main
function, start by defining some constants.commandConstant
represents the command that needs to be sent to the microcontroller. We will use these constants ahead in this code and compare them with the user input to determine whether a CLI command has been entered:const ( ...