Time Action with DS1307

hello everybody

I´ve got a Arduino Ethernet combined with at Grove DS1307 RTC, and i works very well.

My problem is to make a sketch where I can put the actually minute to a integer. I thought I could do:
now.minute() = myownminute

and the make some like:
if myownminute = 15 {
do this action
delay(5000)
}

Does it give sence ? (I´m sorry, but I could have misunderstood something. I´m new into this programming)

I need to read the actually minute state, so I can call an action to do, at a specified time.

I thought I could do: now.minute() = myownminute

No. now is an instance of a class. The minute() method is a function that returns a value. You have the pieces on the wrong sides of the equals sign.

int someMinute = now.minute();

When I´m trying int = someinute =now.minute();

I got an errormessage, that now is not declared in the scope - Do you know what I need to declare in the scope?

Thanks for your help undtil now.!

When I´m trying
int = someinute =now.minute();

Only one equal sign per statement, generally.

I got an errormessage, that now is not declared in the scope - Do you know what I need to declare in the scope?

Well, since I don’t know what scope you declared the variable in, nor the scope that you are trying to access it in, then, no.

Post some real code. All of it.

//______________include
#include <SD.h>
#include <Wire.h>
#include “RTClib.h”
RTC_DS1307 RTC;

//______________kontanter
// this constant won’t change:
const int buttonPin = 7; // the pin that the pushbutton is attached to
const int chipSelect = 4;

//______________variabler
// Variables will change:
int AntalPulser = 0; // counter for the number of button presses
int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button
int someMinute = 0;
String dataString = “”;

//______________void setup
void setup()
{
// initialize the button pin as a input:
pinMode(buttonPin, INPUT);
// initialize serial communication:
Serial.begin(9600);

Serial.print(“Initializing SD card…”);
// make sure that the default chip select pin is set to
// output, even if you don’t use it:
pinMode(10, OUTPUT);

// see if the card is present and can be initialized:
if (!SD.begin(chipSelect))
{
Serial.println(“Card failed, or not present”);
// don’t do anything more:
return;
}
Serial.println(“card initialized.”);
Wire.begin();
RTC.begin();
if (! RTC.isrunning())
{
Serial.println(“RTC is NOT running!”);
// following line sets the RTC to the date & time this sketch was compiled
}
DateTime now = RTC.now();
Serial.print(“Klokken er nu: “);
Serial.print(now.year(), DEC);
Serial.print(’/’);
Serial.print(now.month(), DEC);
Serial.print(’/’);
Serial.print(now.day(), DEC);
Serial.print(’ ‘);
Serial.print(now.hour(), DEC);
Serial.print(’:’);
Serial.print(now.minute(), DEC);
Serial.print(’:’);
Serial.print(now.second(), DEC);
Serial.println();
File dataFile = SD.open (“opstart.txt”, FILE_WRITE);
if (dataFile){
dataFile.print(now.year(), DEC);
dataFile.print(”/”);
dataFile.print(now.month(), DEC);
dataFile.print("/");
dataFile.print(now.day(), DEC);
dataFile.print(" “);
dataFile.print(now.hour(), DEC);
dataFile.print(”:");
dataFile.print(now.minute(), DEC);
dataFile.println();
dataFile.close();
}
}

//______________void loop

void loop() {
//Counter
// read the pushbutton input pin:
buttonState = digitalRead(buttonPin);

// compare the buttonState to its previous state
if (buttonState != lastButtonState)
{
// if the state has changed, increment the counter
if (buttonState == HIGH)
{
// if the current state is HIGH then the button
// wend from off to on:
AntalPulser++;
Serial.print("Antal: ");
Serial.println(AntalPulser);
}
}
// save the current state as the last state,
//for next time through the loop
lastButtonState = buttonState;
//_____________________SD-KORT
// Data som skal flyttes til SD-kort skal ligges i dataString
if () // Need to find out how to trigger this with clock
{
File dataFile = SD.open (“datalog.txt”, FILE_WRITE);
if (dataFile)
{
dataFile.println(dataString);
dataFile.close();
}
}

//_____________________TJEK KLOK

int someMinute = now.minute(); // test

} // ENDER

PoulS -> I´ve tried to make the counting of the pulses, that works. I´ve done the log to the SD-card, but I still need the trigger, from time.

I´m really gone into a black hole, and don´t know how to get away from it.

if () // Need to find out how to trigger this with clock

if(now.minute() % 10 == 0 && now.second() == 0)

The first part will be true when now.minute() returns 0, 10, 20, 30, 40, and 50. The second part causes the while thing to be true only at xx:00:00, xx:10:00, etc. As long as the actual logging takes more than a second, you will only log once every ten minutes.

If logging takes less than a second, you may log more than one time at xx:x0:00. If that happens, add a (global) boolean, set to true in an else block following the if statement. In the if block. test whether that variable is true. If so, log an event, then set the flag to false.