Skip to content

Latest commit

 

History

History

03

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Serial Demo

The Arduino IDE does not offer any debugging capabilities. A common issue for any microcontroller is how to find programming errors in the absense of a debugger. The Arduino offers a way to print debug messages to what is called the Serial Monitor. C++ class Serial has methods (i.e., functions of a C++ class) to interact with the serial interface of an Arduino. In order to use the the serial interface, it must first be initialized via Serial.begin(). This typically happens in the setup() function. The parameter to method Serial.begin() indicates the transmission speed (in the example below it is 9600 bits per second, or 9600 baud). Once the serial interface has been initialized, method Serial.println() can be used to print log messages. This example does not require any wiring. The sketch below will print log messages to the serial monitor. Before compiling and running the sketch, the serial monitor must be opened from the Arduino IDE via the menu option Tools > Serial Monitor. Note that the transmission speed of the serial monitor needs to match the speed configured in the sketch. The sketch below will print "Inside loop()" every 1000 milli seconds (i.e., every 1 second).

void setup() {
  Serial.begin(9600);
  Serial.println("Inside setup()");
}

void loop() {
  Serial.println("Inside loop()");
  delay(1000);
}