i am using a ds1307 rtc and a uno. making a pretty basic light timer. i have the rtc hooked up with a sensor shield and can get it to print in the serial monitor. the problem is that when i set my if statement to turn on the led connected to pin 13 the led will not light up here is my code and still no led action
#include <WProgram.h>
#include <Wire.h>
#include <DS1307.h>
int HR;
int MIN;
int SEC;
void setup()
{
Serial.begin(9600);
pinMode(13, OUTPUT);
RTC.stop();
RTC.set(DS1307_SEC,1); //set the seconds
RTC.set(DS1307_MIN,50); //set the minutes
RTC.set(DS1307_HR,1); //set the hours
RTC.set(DS1307_DOW,4); //set the day of the week
RTC.set(DS1307_DATE,15); //set the date
RTC.set(DS1307_MTH,9); //set the month
RTC.set(DS1307_YR,11); //set the year
RTC.start();
}
void loop()
{
Serial.print(RTC.get(DS1307_HR,true)); //read the hour and also update all the values by pushing in true
Serial.print(":");
Serial.print(RTC.get(DS1307_MIN,false));//read minutes without update (false)
Serial.print(":");
Serial.print(RTC.get(DS1307_SEC,false));//read seconds
Serial.print(" "); // some space for a more happy life
Serial.print(RTC.get(DS1307_DATE,false));//read date
Serial.print("/");
Serial.print(RTC.get(DS1307_MTH,false));//read month
Serial.print("/");
Serial.print(RTC.get(DS1307_YR,false)); //read year
Serial.println();
delay(1000);
if (HR == 1, MIN == 50, SEC == 30){
digitalWrite (13, HIGH);
}
}
hey awol i switched the commas to logical ands and still no led light any other ideas? i know the led works cause i can use the blink example and it blinks and i have this set up like that one for the led logic commands
i used the && for and. as far as the debug that s the console at the bottom correct? its empty except for the binary sketch size the program compiles and runs fine the serial monitor shows the time tickin away but no led action
#include <WProgram.h>
#include <Wire.h>
#include <DS1307.h>
int HR;
int MIN;
int SEC;
void setup()
{
Serial.begin(9600);
pinMode(13, OUTPUT);
RTC.stop();
RTC.set(DS1307_SEC,1); //set the seconds
RTC.set(DS1307_MIN,50); //set the minutes
RTC.set(DS1307_HR,1); //set the hours
RTC.set(DS1307_DOW,4); //set the day of the week
RTC.set(DS1307_DATE,15); //set the date
RTC.set(DS1307_MTH,9); //set the month
RTC.set(DS1307_YR,11); //set the year
RTC.start();
}
void loop()
{
Serial.print(RTC.get(DS1307_HR,true)); //read the hour and also update all the values by pushing in true
Serial.print(":");
Serial.print(RTC.get(DS1307_MIN,false));//read minutes without update (false)
Serial.print(":");
Serial.print(RTC.get(DS1307_SEC,false));//read seconds
Serial.print(" "); // some space for a more happy life
Serial.print(RTC.get(DS1307_DATE,false));//read date
Serial.print("/");
Serial.print(RTC.get(DS1307_MTH,false));//read month
Serial.print("/");
Serial.print(RTC.get(DS1307_YR,false)); //read year
Serial.println();
delay(1000);
if (HR == 1 && MIN && 50, SEC && 30){
digitalWrite (13, HIGH);
}
}
sry i put stuff in the qrong spot there lol here it is now
#include <WProgram.h>
#include <Wire.h>
#include <DS1307.h>
int HR;
int MIN;
int SEC;
void setup()
{
Serial.begin(9600);
pinMode(13, OUTPUT);
RTC.stop();
RTC.set(DS1307_SEC,1); //set the seconds
RTC.set(DS1307_MIN,50); //set the minutes
RTC.set(DS1307_HR,1); //set the hours
RTC.set(DS1307_DOW,4); //set the day of the week
RTC.set(DS1307_DATE,15); //set the date
RTC.set(DS1307_MTH,9); //set the month
RTC.set(DS1307_YR,11); //set the year
RTC.start();
}
void loop()
{
Serial.print(RTC.get(DS1307_HR,true)); //read the hour and also update all the values by pushing in true
Serial.print(":");
Serial.print(RTC.get(DS1307_MIN,false));//read minutes without update (false)
Serial.print(":");
Serial.print(RTC.get(DS1307_SEC,false));//read seconds
Serial.print(" "); // some space for a more happy life
Serial.print(RTC.get(DS1307_DATE,false));//read date
Serial.print("/");
Serial.print(RTC.get(DS1307_MTH,false));//read month
Serial.print("/");
Serial.print(RTC.get(DS1307_YR,false)); //read year
Serial.println();
delay(1000);
if (HR == 1 && MIN == 50 && SEC == 30){
digitalWrite (13, HIGH);
}
}
well thank you nick that was very helpfull my led light uo right when it was supposed to. i understand what you said now also. my fishies thank you vey much.