/*
DS3231: Real-Time Clock. Simple example
Read more:
http://www.jarzebski.pl/arduino/komp...tc-ds3231.html
GIT:
https://github.com/jarzebski/Arduino-DS3231
Web: /dev/Jarzębski - Santyago back to root
(c) 2014 by Korneliusz Jarzebski
*/
#include <SPI.h>
#include <SD.h>
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9340.h"
#include <Wire.h>
#include <DS3231.h>
#if defined(__SAM3X8E__)
#undef __FlashStringHelper::F(string_literal)
#define F(string_literal) string_literal
#endif
// These are the pins used for the UNO
// for Due/Mega/Leonardo use the hardware SPI pins (which are different)
#define _sclk 13
#define _miso 12
#define _mosi 11
#define _cs 10
#define _dc 9
#define _rst 8
Adafruit_ILI9340 tft = Adafruit_ILI9340(_cs, _dc, _rst);
const int chipSelect = 4; //number of pin cs of sd-card
DS3231 clock;
RTCDateTime dt;
// String k;//="ali"
String SENDSTR (void)
{
String k=String(clock.dateFormat("Y-m-d l H:i:s", dt));
return k; }
void setup()
{
Serial.begin(9600);
// Initialize DS3231
Serial.println("Initialize DS3231");;
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
return; // don't do anything more:
}
Serial.println("card initialized.");
// Set sketch compiling time
clock.begin();
clock.setDateTime(__DATE__, __TIME__);
dt = clock.getDateTime();
String k=String(clock.dateFormat("Y-m-d l H:i:s", dt));
String M =(clock.dateFormat("Y-m-d l H:i:s", dt));
Serial.println("k =");Serial.println(k);
Serial.println("M =");Serial.println(M);
File dataFile = SD.open(SENDSTR(), FILE_WRITE);
dataFile.println(clock.dateFormat("Y-m-d l H:i:s", dt));
dataFile.println("YA ALI MADAD");
dataFile.close();
}
void loop()
{
dt = clock.getDateTime();
Serial.print("Value of SENDSTR()= ");Serial.println(SENDSTR());
File dataFile = SD.open(SENDSTR(), FILE_WRITE);
dataFile.println("ljksadfljsfljslfjlsjf");
dataFile.close();
Serial.print("Raw data: ");
Serial.print(dt.year); Serial.print("-");
Serial.print(dt.month); Serial.print("-");
Serial.print(dt.day); Serial.print(" ");
Serial.print(dt.hour); Serial.print(":");
Serial.print(dt.minute); Serial.print(":");
Serial.print(dt.second); Serial.println("");
delay(1000);
}