0
votes

A newbie question, I know. But, I've seldom used serial ports. Now I'm working with Arduino and c++. In researching methods for reading/writing to the serial port, I'm finding several. I'd like to know the differences. Serial.print - Serial.println - Serial.write, just to name a few and this is just on the sending side. Why would I want to use one instead of another? -Thanks

1
println will print a new line. First big difference. :)herohuyongtao
Just read arduino's library's docDavidbrcz
Arduino is just a platform name. The actual hardware is based on an Atmel part. Read up on the microcontroller you're using and you'll find information on the peripheral that can read and write serial data. As for the Arduino library functions (Serial.print), use the reference. I'm assuming Serial.print will send a string where as Serial.write sends a single character.bblincoe
Thanks for your response. I've been searching the Microsoft docs, both online and off, since I'm using Visual Studio C++. Not much there. I never thought to look at the Arduino site. Println is supposed to add a cr and lf to the end, however, I don't see that happening; print does not, and write is to send binary data, whereas the other two are ascii. I can live with that.user3210124

1 Answers

0
votes

The difference between Serial.print() and Serial.println() is that println includes the cr and LF.

The best way to see this is with the Arduino Serial Monitor.