Go Down

Topic: Newbi need some help please (Read 6 times) previous topic - next topic

AWOL

Quote
but the use milis, why did i get a RTC then?

"millis" tells you the time that has elapsed since the last reset.
An RTC should retain the time even if the processor is reset or powered-off.
"millis" and "micros" also give you the time in smaller increments than most RTCs.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

kimbo001

I Know HazardsMind it was aimed at AWOL
You been helping a lot thank you

AWOL

Quote
it was aimed at AWOL

OK, bye.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

kimbo001

AWOL i am a pc Tech and the obvious things for me is not so obvious for the public i work with, sometimes i cant understand why they don't understand things that is second nature to me. So i know why you getting fed up with me asking so much, i don't understand the obvious to you, hence the questions.
I felt today like the ppl that come to me for advice, there is no excuse for my behavior.
I am sorry for shouting at you

kimbo001

For ppl that is interested in te code to control a pin with a RTC here is the code. The pin(in this case 8) will be high for the ten secs the if statement is true. After ten secs the pin will go low

Code: [Select]
#include <Wire.h>
#include "RTClib.h"

RTC_DS1307 RTC;
int ledPin = 8;

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


  RTC.adjust(DateTime(__DATE__, __TIME__));
  pinMode (ledPin, OUTPUT);
}

void loop()   
{
  DateTime now = RTC.now(); 
  Serial.print(" Time = ");
  Serial.print(now.hour(), DEC);
  Serial.print(':');
  Serial.print(now.minute(), DEC);
  Serial.print(':');
  Serial.print(now.second(), DEC);
  Serial.println();
  delay(3000);
  if (now.hour() == 20 && now.minute() == 56 && now.second() < 10)
      digitalWrite(ledPin, HIGH);   
  else {
    digitalWrite(ledPin, LOW);
}
}

HazardsMind

You still need to take out "delay(3000);" , its not needed. Also now.second() < 10, is not for ANY 10 seconds, but for when the clock changes from say (example) 5 minutes to 6 minutes. The LED is only ON for the first 10 seconds, of the NEW minute. Actually it would be 7 seconds, since you have that 3 second delay still in there.

Just pointing that out.

kimbo001

Tx HazardsMind
My objective with this was so that when i get my motor shield i will adapt the code to activate a dc motor at say 8am in and run it for ten seconds, then it will stop. Thant will be the time it takes from a closed blind to open them.

HazardsMind


Go Up