I just cant seem to figure out how to print it i keep getting this error from my code:
C:\Users*my name*\Documents\code\send help 2\send help 2.ino: In function 'void loop()':
C:\Users*my name*\Documents\code\send help 2\send help 2.ino:104:29: error: invalid use of void expression
dataFile.print(printTime());
^
exit status 1
Compilation error: invalid use of void expression
Code(Send help 2):
#include <SPI.h>
#include <SparkFunDS3234RTC.h>
#define DS13074_CS_PIN 10 // DeadOn RTC Chip-select pin
#define INTERRUPT_PIN 2 // DeadOn RTC SQW/interrupt pin (optional)
#include <SD.h>
File dataFile;
const int chipSelect = 4; //SD card CS pin connected to pin 10 of Arduino
void setup()
{
// Use the serial monitor to view time/date output
Serial.begin(9600);
#ifdef INTERRUPT_PIN // If using the SQW pin as an interrupt
pinMode(INTERRUPT_PIN, INPUT_PULLUP);
#endif
rtc.begin(DS13074_CS_PIN);
rtc.autoTime();
rtc.update();
rtc.enableAlarmInterrupt();
rtc.setAlarm1(30);
rtc.setAlarm2(rtc.minute() + 1);
// setup for the SD card
Serial.print("Initializing SD card...");
if(!SD.begin(chipSelect)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
//open file
dataFile = SD.open("LOGDATA.txt", FILE_WRITE);
// if the file opened ok, write to it:
if (dataFile) {
Serial.println("File opened ok");
// print the headings for our data
dataFile.println("Date,Time");
}
dataFile.close();
Serial.println("CLEARDATA"); //clears up any data left from previous projects
Serial.println("LABEL,Date,Logging Time,Time,Temperature,Light Intensity %, POT %"); //always write LABEL, to indicate it as first line
Serial.println("RESETTIMER");
}
void loop()
{
static int8_t lastSecond = -1;
// Call rtc.update() to update all rtc.seconds(), rtc.minutes(),
// etc. return functions.
rtc.update();
if (rtc.second() != lastSecond) // If the second has changed
{
printTime(); // Print the new time
lastSecond = rtc.second(); // Update lastSecond value
}
// Check for alarm interrupts
#ifdef INTERRUPT_PIN
// Interrupt pin is active-low, if it's low, an alarm is triggered
if (!digitalRead(INTERRUPT_PIN))
{
#endif
// Check rtc.alarm1() to see if alarm 1 triggered the interrupt
if (rtc.alarm1())
{
Serial.println("ALARM 1!");
// Re-set the alarm for when s=30:
rtc.setAlarm1(30);
}
// Check rtc.alarm2() to see if alarm 2 triggered the interrupt
if (rtc.alarm2())
{
Serial.println("ALARM 2!");
// Re-set the alarm for when m increments by 1
rtc.setAlarm2(rtc.minute() + 1, rtc.hour());
}
#ifdef INTERRUPT_PIN
}
#endif
dataFile = SD.open("LOGDATA.txt", FILE_WRITE);
// if the file is available, write to it:
if (dataFile) {
dataFile.print(printTime());
}
}
void printTime()
{
Serial.print(String(rtc.hour()) + ":"); // Print hour
if (rtc.minute() < 10){
Serial.print('0'); // Print leading '0' for minute
Serial.print(String(rtc.minute()) + ":"); // Print minute
}
if (rtc.second() < 10){
Serial.print('0'); // Print leading '0' for second
Serial.print(String(rtc.second())); // Print second
}
if (rtc.is12Hour()) // If we're in 12-hour mode
{
// Use rtc.pm() to read the AM/PM state of the hour
if (rtc.pm()) Serial.print(" PM"); // Returns true if PM
else Serial.print(" AM");
}
Serial.print(" | ");
// Few options for printing the day, pick one:
Serial.print(rtc.dayStr()); // Print day string
//Serial.print(rtc.dayC()); // Print day character
//Serial.print(rtc.day()); // Print day integer (1-7, Sun-Sat)
Serial.print(" - ");
#ifdef PRINT_USA_DATE
Serial.print(String(rtc.month()) + "/" + // Print month
String(rtc.date()) + "/"); // Print date
#else
Serial.print(String(rtc.date()) + "/" + // (or) print date
String(rtc.month()) + "/"); // Print month
#endif
Serial.println(String(rtc.year())); // Print year
}