Transmitting data over serial communication
Code debugging is a fundamental process of software development to identify errors in code.
This recipe will demonstrate how to conduct print debugging on the Arduino Nano and Raspberry Pi Pico by transmitting the following strings to the serial terminal:
Initialization completed
: once the serial port on the microcontroller has finished initializingExecuted
: after every 2 seconds of program execution
Getting ready
All programs are prone to bugs, and print debugging is a basic process that displays statements on the output terminal, providing valuable insight into the program’s execution, as shown in the following example:
int func (int func_type, int a) {
int ret_val = 0;
switch(func_type){
case 0:
printf("FUNC0\n");
ret_val = func0(a)
break;
default:
printf("FUNC1\n");
ret_val = func1(a);
}
return ret_val;
}
In the preceding...