Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
documentation:microcontroleurs:arduino:modules:sdcard:index [2021/06/24 16:03] – [CODE] f1sls | documentation:microcontroleurs:arduino:modules:sdcard:index [2022/09/13 08:29] (Version actuelle) – [PINOUTS] f1sls | ||
---|---|---|---|
Ligne 2: | Ligne 2: | ||
====== MODULES SD CARD ====== | ====== MODULES SD CARD ====== | ||
- | ===== PINOUT | + | ===== PINOUTS |
{{: | {{: | ||
+ | ---- | ||
+ | {{: | ||
===== SD-CARD + ARDUINO ===== | ===== SD-CARD + ARDUINO ===== | ||
{{: | {{: | ||
+ | ---- | ||
+ | {{: | ||
+ | ---- | ||
+ | {{: | ||
+ | ===== CODE ===== | ||
- | + | ==== WRITING | |
- | ===== CODE ===== | + | < |
- | < | + | |
#include < | #include < | ||
#include < | #include < | ||
Ligne 60: | Ligne 66: | ||
// nothing happens after setup | // nothing happens after setup | ||
} | } | ||
+ | </ | ||
+ | |||
+ | ==== READING ==== | ||
+ | <code cpp> | ||
+ | #include < | ||
+ | #include < | ||
+ | File myFile; | ||
+ | |||
+ | void setup() { | ||
+ | |||
+ | // Open serial communications and wait for port to open: | ||
+ | Serial.begin(9600); | ||
+ | |||
+ | while (!Serial) { | ||
+ | ; // wait for serial port to connect. Needed for native USB port only | ||
+ | } | ||
+ | |||
+ | Serial.print(" | ||
+ | if (!SD.begin(10)) { | ||
+ | Serial.println(" | ||
+ | while (1); | ||
+ | } | ||
+ | |||
+ | Serial.println(" | ||
+ | |||
+ | // open the file for reading: | ||
+ | myFile = SD.open(" | ||
+ | | ||
+ | if (myFile) { | ||
+ | Serial.println(" | ||
+ | |||
+ | // read from the file until there' | ||
+ | while (myFile.available()) { | ||
+ | Serial.write(myFile.read()); | ||
+ | } | ||
+ | |||
+ | // close the file: | ||
+ | myFile.close(); | ||
+ | | ||
+ | } else { | ||
+ | // if the file didn't open, print an error: | ||
+ | Serial.println(" | ||
+ | } | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | // nothing happens after setup | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | |||
+ | ==== READING LINE BY LINE ==== | ||
+ | <code cpp> | ||
</ | </ |