A common pattern in Arduino C++ sketches is the use of Serial.print()
or Serial.println()
to debug problems.
What is the corresponding Rust idiom when programming for the Arduino Uno?
A common pattern in Arduino C++ sketches is the use of Serial.print()
or Serial.println()
to debug problems.
What is the corresponding Rust idiom when programming for the Arduino Uno?
One technique involves the use of arduino_hal::default_serial!
and ufmt::writeln!
For setup:
let dp = arduino_hal::Peripherals::take().unwrap();
let pins = arduino_hal::pins!(dp);
let mut serial = arduino_hal::default_serial!(dp, pins, 115200);
and when you need to print
ufmt::uwriteln!(&mut serial, "{} bytes available", count);
The uwriteln!
macro is not as powerful as format!
or println!
from std
. For instance, it does not support {:02x}
for integers.