arduino-libraries / SD

SD Library for Arduino

Home Page:http://arduino.cc/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Typo in message printed by Serial.print() when SD card fails to initialize

Inv3nt0r1 opened this issue · comments

There is a typo in a message printed by Serial.print() when the SD card fails to initialize that can misguide new users.

Thanks @per1234, for giving accurate information.

#79 (comment)

the sketch is restarted whenever the serial monitor is opened

This is only true for the Arduino boards that use an external USB to serial adapter chip that uses the DTR trick you mentioned. It is not true when using a native USB board (e.g., Leonardo, MKR, Nano 33 IoT, Nano 33 BLE). The serial connection with Serial Monitor is also lost when those boards are reset, so you do need to both a reset and a Serial Monitor restart to get the example sketches to start again and show serial output.

At the time those instructions were written, it's likely all Arduino boards had the reset on Serial Monitor open behavior, so they were correct at that time. Most of Arduino's new boards now have native USB, so the existing instructions become even more outdated over time.

Credits: @per1234

Serial.println("Note: press reset or reopen this serial monitor after fixing your issue!");

if (!SD.begin(4)) {
    Serial.println("initialization failed. Things to check:");
    Serial.println("1. is a card inserted?");
    Serial.println("2. is your wiring correct?");
    Serial.println("3. did you change the chipSelect pin to match your shield or module?");
    Serial.println("Note: press reset or reopen this serial monitor after fixing your issue!");
    while (1);
  }

It should be Press reset button and reopen serial monitor after fixing your issue.

Also, this message can be added to other examples as well.

Thank you.