Jeff,
I’ve attempted to follow the instructions in your previous post.
etc.
Latest version of the sketch:
t#include "SD.h" // SD card library
#include "Wire.h" // I2C
#include "Time.h" // Time Manipulation
#include "DS1307RTC.h" // DS1307 RTC
File file; // test file
const uint8_t SD_CS = 10; // SD chip select
char timestamp[30];
//------------------------------------------------------------------------------
// call back for file timestamps
void dateTime(uint16_t* date, uint16_t* time) {
sprintf(timestamp, "%02d:%02d:%02d %2d/%2d/%2d \n", tm.Hour(),tm.Minute(),tm.Second(),tm.Month(),tm.Day(),tm.Year()-2000);
Serial.println("yy");
Serial.println(timestamp);
// return date using FAT_DATE macro to format fields
*date = FAT_DATE(tm.Year(), tm.Month(),tm.Day());
// return time using FAT_TIME macro to format fields
*time = FAT_TIME(tm.Hour(),tm.Minute(),tm.Second());
}
// constants won't change. They're used here to set pin numbers:
const int SWITCH_PIN = 2; // the number of the microswitch pin
char timedatebuf[65]; // Time and Date string buffer
int year4digit; // 4 digit year
char shutterStatus[24];
void setup()
{
Serial.begin(9600); // Serial monitor used for testing
// Micro switch code
pinMode (SWITCH_PIN, INPUT_PULLUP);
Serial.println("Micro switch project");
pinMode(10, OUTPUT);
if (!SD.begin(10)) { // check if card is installed
Serial.println("No SD Card present in module");
return;
}
// set date time callback function
SdFile::dateTimeCallback(dateTime);
Serial.println("SD Card Ready");
}
void loop()
{
tmElements_t tm;
// Micro switch code
int microSwitch = digitalRead(SWITCH_PIN);
if (microSwitch == LOW)
{
strcpy(shutterStatus, "Shutters Open");
}
else
{
strcpy(shutterStatus, "Shutters Closed");
}
if (RTC.read(tm)) // Get Time/Date from RTC1307
{
year4digit = tm.Year + 1970; // 4 digit year variable
// Format Time & Date string in timedatebuf
sprintf(timedatebuf, "%s Time: %02d:%02d:%02d Date: %02d/%02d/%02d", shutterStatus, tm.Hour, tm.Minute, tm.Second, tm.Day, tm.Month, year4digit);
File dataFile = SD.open("SHUTTERS.txt", FILE_WRITE); // Open or Create file
if (dataFile) // Check if file exist on SD Card
{
dataFile.println(timedatebuf);
dataFile.close(); // Close file
Serial.println(timedatebuf);
}
else
{
Serial.println("error opening shutters.txt"); // if file not on SD Card
}
}
delay(1000);
}
When I compile it, Arduino generates an error report relative to three lines in the code: 15, 19 and 22. Each error, following the position reference, is described thus: error: expected primary-expression before ‘.’ token referring to Google, I have not found any clear direction as to the amendment required to enable compilation.
Finally, at the end of the error report it states the following:
exit status 1
Compilation error: expected primary-expression before ‘.’ token