Please guys i wrote this sketch to control my led
to be on from 7am to 7pm
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 rtc;
void setup()
{
Wire.begin();
rtc.begin();
if (! rtc.isrunning())
{
Serial.println("RTC is NOT running!");
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
pinMode(13, OUTPUT);
}
void loop()
{
DateTime now = rtc.now();
// les deux lignes suivantes ne servent qu'au debugage, elles pourront etre supprimées
Serial.print(now.hour(), DEC); //pour afficher l'heure sur le moniteur
delay(5000); //pour avoir le temps de lire le moniteur
if ((now.hour() > 07) && (now.hour() < 19))
{
digitalWrite(13, 0);
}
else
{
digitalWrite(13, 1);
}
}
but now i don't know how to wire up the RTC and the LED to test the sketch on ISIS
if it works or not
if anyone can help me with that i'll be grartful
didyi:
ISIS is a simulation softwar
how could i wire up those composants to test the sketch
You need no testing software to see, that you programmed starting hour wrong by one hour:
if ((now.hour() > 07) && (now.hour() < 19))
This means: Switching starts at 8:00:00 (which is hour >7). So better use:
if ((now.hour() >= 7) && (now.hour() < 19))
And your number with leading zero "07" is just by chance correct.
With a leading 0 the number is an "octal number" in C/C++ syntax and NOT a decimal number!
So don't try that with 08 or 09 or you see a compile error!
To use decimal numbers, don't write a leading zero!
Leading zeros as a prefix before a number have a special meaning in C:
0x ==> hexadecimal number
0b ==> binary number
0 ==> octal number
and every number starting with 1, 2, 3, ... 9 is a decimal number.
If this is a question about Proteus/ISIS simulation software: Wrong forum, most likely.
In this forum you'll typically meet persons that connect real DS1307 modules to real Arduino boards.