Модуль SD карты

Подключение модуля SD карты к плате Arduino. Запись данных на SD карту
#include <SPI.h>
#include <SD.h>
int x = 0;
 
void sd_print(String file, String texttoprint, boolean lf)
  {
   File sd_file;
    sd_file = SD.open(file, FILE_WRITE);
  if(sd_file){
    if(lf)sd_file.println(texttoprint);
    else sd_file.print(texttoprint);
    sd_file.close();
  }
}

void setup() {
  SD.begin(10);
}

void loop() {
    x = analogRead(A0);
    sd_print("NAME.TXT",(String("ArduBlock - ") + String(x)),true);
    delay(500);
} 

Открыть пример: Online ArduBlock



Чтение данных с SD карты.
#include <SPI.h>
#include <SD.h>

String values;

void setup() {
  Serial.begin(9600);
  SD.begin(10);
  File myFile = SD.open("123.txt");
    if (myFile)
  {
    byte h = 0;
    char text[] = {};
    while (myFile.available())
    {
     text[h] = myFile.read();
      h++;
    }
    values = text;
    myFile.close();
 }
}

void loop() {
    Serial.println(values);
    delay(1000);
} 

Открыть пример: Online ArduBlock



Видеоурок:

Компоненты с Aliexpress:

Arduino Uno

Потенциометр

SD модуль

Макетная плата