Advertisement
vbprojects

Code pour module Micro SD

Nov 13th, 2019
499
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*CS -> 4
  2. SCK -> 52
  3. MOSI -> 51
  4. MISO -> 50*/
  5.  
  6. #include <SD.h>
  7.  
  8. File file;
  9. String test;
  10.  
  11. void setup() {
  12.   Serial.begin(9600);
  13.  
  14.   Serial.print("Starting SD...");
  15.  
  16.   if(!SD.begin(4)) Serial.println("failed");
  17.   else Serial.println("ok");
  18.  
  19.   file = SD.open("file.txt", FILE_WRITE);
  20.   if(file){
  21.     file.println("Je suis à la ligne une");
  22.     file.print("Je suis SENCE être à la ligne 2");
  23.     file.print(" Et moi à la suite mdr");
  24.     file.close();
  25.   }
  26. }
  27.  
  28. void loop() {
  29.   file = SD.open("file.txt", FILE_READ);
  30.   if(file){
  31.     test = file.read();
  32.     file.close();
  33.   }
  34.   Serial.println(test);
  35.   delay(5000);
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement