Writing to the serial port
An easy way to debug your programs on a microcontroller is to write messages to the serial port. You can later use this technique to debug your program, by printing the current step or sensor values, for example.
Let's write a small program to see how writing to a serial port is done. We start by creating a new folder named Chapter03
in the project directory, and inside this new directory, we create another directory named writing-to-serial
. Now we have to create a new main.go
file and insert an empty main()
function. The folder structure should now look like the following:
Now, follow these steps:
- We print the word
starting
followed by a space and print the wordprogram
followed by an\n
:print("starting ") print("program\n")
- We endlessly loop, print
Hello World
, and sleep for a second:for { println("Hello...