PC AND DASDUINO’S SERIAL COMMUNICATION – SERIAL MONITOR

There are many ways to read and write on the Serial Port using Arduino, and here we will demonstrate the simplest one. Make sure to use it in order to avoid frustrating ways! 🙂 While we have just briefly turned to Serial Monitor in previous tutorials, in this one, we will explain in detail how to work with it, whether with Arduino IDE or Atmel AVR Studio. Generally, Serial Monitor can be used with any serial device connected to your computer.Â
SERIAL MONITOR
Serial Monitor is an addition to the Arduino IDE software. You have most likely already come across it if you have ever done some Arduino project, e.g. reading the temperature off the DHT sensor. Besides reading the current code condition, it allows sending and receiving text messages and as such it is very practical in tracing errors in the code (debugging, controlling Dasduino using a keyboard or for viewing the data printout). But, one by one..
Note: before moving on, connect the Dasduino board and select Board and Port under Tools tab of the Arduino IDE softwareÂ
Serial monitor is initiated by clicking on the magnification icon or using the Ctrl+Shift+M key combination.
Basic properties:
COM Port – virtual port through which we want to create serial communication between the computer and the Dasduino boardÂ
BAUDÂ –Â a unit of pulse per second for the UART communication
LINE ENDING:Â (detailed)
No line editing – sends what is written
Newline – to the written text, it adds ASCII symbol for new line (equivalent to “\n”)
Carriage return – to the written text, it adds ASCII symbol for return (equivalent to “\r”)
Both NL & CRÂ – to the written text, it adds both Newline and Carriage return
DASDUINO TO SERIAL MONITOR
We begin the serial communication with Serial.begin(); which is set in the setup part of the code. The parameter assigned to the function is BAUD rate. It has to coincide with the one from the Serial Monitor so that we do not read “hieroglyphs” that may occur because of incompatibility in the speed of communication.
SERIAL MONITOR TO DASDUINO
Reading commands:
Serial.read()Â – reads the first byte of the default variable
int
sm_int = 0;
void
setup
() {
 Â
// beginning serial communication
 Â
Serial.begin(9600);
// the same BAUD Rate is set in the Serial Monitor
}
void
loop
() {
 Â
if
( Serial.available() ) {
   Â
sm_int = Serial.read();
   Â
Serial.println(sm_int, DEC);
 Â
}
}
Serial.readString() – reads the default variable and saves it to String