Skip to content

Instantly share code, notes, and snippets.

@komponenrobot
Created March 24, 2020 16:53
Show Gist options
  • Save komponenrobot/e32fd3c5afc85dfd7cc69e6126ac7845 to your computer and use it in GitHub Desktop.
Save komponenrobot/e32fd3c5afc85dfd7cc69e6126ac7845 to your computer and use it in GitHub Desktop.
sd_gantiNama
#include "FS.h"
#include "SD.h"
#include "SPI.h"
#define SD_CS 5
void renameFile(fs::FS &fs, const char * path1, const char * path2){
Serial.printf("Renaming file %s to %s\n", path1, path2);
if (fs.rename(path1, path2)) {
Serial.println("File renamed");
} else {
Serial.println("Rename failed");
}
}
void setup(){
Serial.begin(9600);
SD.begin(SD_CS);
if (!SD.begin(SD_CS)) {
Serial.println("Gagal Memuat Kartu SD");
return;
}
uint8_t cardType = SD.cardType();
if (cardType == CARD_NONE) {
Serial.println("Tidak Ada Kartu SD");
return;
}
Serial.println("Menginisialisasi kartu SD...");
renameFile(SD, "/RobotikID.txt", "/RobotikIndonesia.txt");
/*
Mengganti nama File RobotikID.txt menjadi RobotikIndonesia.txt
*/
}
void loop(){
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment