this led lit up after a while of this code running, what is it for?`
#include <SD.h>// mosi = 11//miso = 12//clk = 13//cs = 10
#include <SPI.h>
#include <virtuabotixRTC.h> //https://github.com/chrisfryer78/ArduinoRTClibrary/tree/master
virtuabotixRTC myRTC (6, 7, 8); //clk, data, rst
void setup() {
Serial.begin(115200);
//sec, min, day of week, day of month, month, year
//myRTC.setDS1302Time(00, 21, 15, 4, 1, 8, 2024); if battery inserted you have need to set same time every start of arduino
while (!Serial);
Serial.print("SD Ready");
if (!SD.begin(10)) {
Serial.println("SD Card Failed");
return;
}
Serial.println("SD Good");
Serial.end(); // no serial need, only for start
}
void loop() {
const int Period = 1000; // millisec between readings
const byte Num = 10; // how much lines collect before store to SD
static char Text[Num ][30]; // i am not sure if attribut static is really need
static byte index = 0;
static unsigned long oldMillis = millis();
if (millis() - oldMillis >= Period ) {
oldMillis += Period ;
myRTC.updateTime();
int readA0 = analogRead(A0);
sprintf(Text[index], "%02u/%02u/%02u %02u:%02u:%02u\t%u\n", myRTC.year, myRTC.month, myRTC.dayofmonth, myRTC.hours, myRTC.minutes, myRTC.seconds, readA0);
index++;
if (index == Num ) {
index = 0;
File myFile = SD.open("lightS" + String(myRTC.hours % 6), FILE_WRITE); // 6 files total
for (int i = 0; i < Num ; i++) myFile.print(Text[i]);
myFile.close();
}
}
}