2

From here I think I understand the difference between Serial.write and Serial.print, but is it the same when writing to a file in a SD card for example. Does it mean that File.write saves bytes in the file instead of text?

1 Answer 1

3

The File class inherits from the Stream class, which in turn inherits from the Print class.

The Serial class inherits from the Stream class, which in turn inherits from the Print class.

print() and write() are defined by the Print class.

So yes, File.print() and Serial.print() are the same, as are File.write() and Serial.Write().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.