Serial Control Blink
Step 1 - Build the Project
Using the serial monitor provides you with a way to send information to and receive information from the Maker Board. Here you send in a variable’s value and the code updates as soon as Maker Board receives the input.
Note about serial monitor: first click "Upload to Maker Board", complete the upload, then click the "Monitor" button in the top toolbar to open the serial monitor. This allows the data to be sent from the Maker Board to the serial monitor. You can enter messages within the serial monitor and click 'send' to send serial messages to Maker Board.
Step 2 - Upload the Code
Step 3 - Read the Walkthrough
The first thing you’ll do is create a variable of the type ‘unsigned long’. You can read up on C++ variable types, but this one allows for very large inputs, so you have have a delay of over 4,000,000,000 milliseconds if you want to. This variable is what your inputs will actually update.
To use the serial monitor, you have to tell the Maker Board to be ready to send and receive information from it. The Serial.begin(9600); command in setup does that and it sets the communication rate at 9600. When you open the serial monitor, make sure that the number in the bottom right hand corner is also 9600. If it isn’t, your communication will be garbled.
Serial.print and Serial.println (pronounced print-line) are the easiest ways to get text onto the serial monitor. The starter message in the setup() will print once, then jump to a new line.
The loop() section is using an if statement to ask “Is there any new information from the serial monitor?” and if there is, the if statement takes that information and puts it into the variable.
Next, that variable is used as the delay for a simple blink of the LED using digitalWrite. After the first blink has ended, the loop checks for new information from the serial monitor.