Include expects error

If i click Verify-button, get this error:

Test:3: error: #include expects "FILENAME" or <FILENAME>
 #include “RTClib.h”
          ^
exit status 1
#include expects "FILENAME" or <FILENAME>

I only commented out two rows of text which is not code at all.

Or do i need to connect Arduino before i click Verify-button?

Original code:

// Date and time functions using DS1307 RTC connected via I2C and Wire lib
#include <Wire.h>
#include “RTClib.h”

#include <SPI.h>
#include <SD.h>

RTC_DS1307 rtc;

File dataFile;

const int buttonWater = 2; // pushbutton connected to digital pin 2
// Water – Button One
int buttonPushCounter = 0;

int buttonStateWater = 0; // current state of the water button
int lastButtonStateWater = 0; // previous state of the button

// Initialize MicroSD card and RTC in Void Setup(). Set button as Input.

void setup()

Serial.begin(9600);
Wire.begin();
rtc.begin();

// Check that the microSD card exists and can be used

Serial.print(“Initializing SD card…”);
pinMode(10, OUTPUT);

if (!SD.begin(10)) {
Serial.println(“Card failed, or not present”);
while (1) ;
}
Serial.println(“card initialized.”);

if (! rtc.isrunning()) {
Serial.println(“RTC is NOT running!”);
// following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(__DATE__, __TIME__));

// Set my digital pins as inputs or outputs
pinMode(buttonWater, INPUT);

}
}

// In Void Loop(), make a string to assemble the data. Read the button as an input. Compare the button states. If the button state goes from off to on, write the data to the dataFile once. Each piece of data that is needed is put into a string (separate strings for month, year, etc.) Date and time data is obtained using Real Time Clock functions. Put all the strings into dataString and write to microSD card. Close the microSD card. Compare button states and repeat if button state changes from previous state.

void loop () {

// Make a string for assembling the data to log:
String dataString = “”;

// RTC Time Function
DateTime now = rtc.now();

// Read the water pushbutton input pin
buttonStateWater = digitalRead(buttonWater);

// compare the buttonState to its previous state
if (buttonStateWater != lastButtonStateWater) {
if (buttonStateWater == HIGH) {
Serial.println(“Button one is pressed”);

// Create the file for writing the data
dataFile = SD.open(“datalog.txt”, FILE_WRITE);

// Assemble Strings to log data
String theyear = String(now.year(), DEC);
String mon = String(now.month(), DEC);
String theday = String(now.day(), DEC);
String thehour = String(now.hour(), DEC);
String themin = String(now.minute(), DEC);
//Put all the time and date strings into one String
dataString = String(“water, ” + theyear + “/” + mon + “/” + theday + “, ” + thehour + “:” + themin);

// Open the datafile and write the dataString to the microSD card
if (dataFile) {
dataFile.println(dataString);
dataFile.close();
Serial.println(dataString);
}

// if the file isn’t open, register an error:
else {
Serial.println(“error opening datalog.txt”);

}
}
}

// save the current state as the last state,
//for next time through the loop
lastButtonStateWater = buttonStateWater;

}

Or do i need to connect Arduino before i click Verify-button?

no you don’t

your problem is likely elsewhere, hit ctrl-T for your code to indent and you’ll see it’s a mess…

You have deleted the opening { bracket for the setup() function → add it back in and all will be correct

void setup()
[color=red]{ // <---- missing bracket here !!!
[/color]   Serial.begin(9600);

Thanks.

I added bracket. It was missing from original code.

Then i did ctrl-T and Arduino highlights #include “RTClib.h” row and shows this error:

Test2:3: error: #include expects "FILENAME" or <FILENAME>
 #include “RTClib.h”
          ^
exit status 1
#include expects "FILENAME" or <FILENAME>

New code:

// Date and time functions using DS1307 RTC connected via I2C and Wire lib
#include <Wire.h>
#include “RTClib.h”

#include <SPI.h>
#include <SD.h>

RTC_DS1307 rtc;

File dataFile;

const int buttonWater = 2; // pushbutton connected to digital pin 2
// Water – Button One
int buttonPushCounter = 0;

int buttonStateWater = 0; // current state of the water button
int lastButtonStateWater = 0; // previous state of the button

// Initialize MicroSD card and RTC in Void Setup(). Set button as Input.

void setup()
{
  Serial.begin(9600);
  Wire.begin();
  rtc.begin();

  // Check that the microSD card exists and can be used

  Serial.print(“Initializing SD card…”);
  pinMode(10, OUTPUT);

  if (!SD.begin(10)) {
    Serial.println(“Card failed, or not present”);
    while (1) ;
  }
  Serial.println(“card initialized.”);

  if (! rtc.isrunning()) {
    Serial.println(“RTC is NOT running!”);
    // following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(__DATE__, __TIME__));

    // Set my digital pins as inputs or outputs
    pinMode(buttonWater, INPUT);

  }
}

// In Void Loop(), make a string to assemble the data. Read the button as an input. Compare the button states. If the button state goes from off to on, write the data to the dataFile once. Each piece of data that is needed is put into a string (separate strings for month, year, etc.) Date and time data is obtained using Real Time Clock functions. Put all the strings into dataString and write to microSD card. Close the microSD card. Compare button states and repeat if button state changes from previous state.

void loop () {

  // Make a string for assembling the data to log:
  String dataString = “”;

  // RTC Time Function
  DateTime now = rtc.now();

  // Read the water pushbutton input pin
  buttonStateWater = digitalRead(buttonWater);

  // compare the buttonState to its previous state
  if (buttonStateWater != lastButtonStateWater) {
    if (buttonStateWater == HIGH) {
      Serial.println(“Button one is pressed”);

      // Create the file for writing the data
      dataFile = SD.open(“datalog.txt”, FILE_WRITE);

      // Assemble Strings to log data
      String theyear = String(now.year(), DEC);
      String mon = String(now.month(), DEC);
      String theday = String(now.day(), DEC);
      String thehour = String(now.hour(), DEC);
      String themin = String(now.minute(), DEC);
      //Put all the time and date strings into one String
      dataString = String(“water, ” + theyear + “ / ” + mon + “ / ” + theday + “, ” + thehour + “: ” + themin);

      // Open the datafile and write the dataString to the microSD card
      if (dataFile) {
        dataFile.println(dataString);
        dataFile.close();
        Serial.println(dataString);
      }

      // if the file isn’t open, register an error:
      else {
        Serial.println(“error opening datalog.txt”);

      }
    }
  }

  // save the current state as the last state,
  //for next time through the loop
  lastButtonStateWater = buttonStateWater;

}

Original code:

http://www.michellechandra.com/physical-computing/activity-tracker-log-date-and-time-to-microsd-using-real-time-clock-and-arduino/

Wrong quotes:
Screen Shot 2017-10-15 at 15.21.08.png

Copy your code back from the forum and it will work