Time checking on reset

I'm a bit stuck if someone can help a bit.
I need to check after each arduino restart time and determine its function.
For example, 9-21 hours should be Led1 HIGH and Led2 should be LOW.
In which part should set this condition?
Below is an example of where I'm stuck at verify.

if (hour()>=9 && hour <21)

digitalWrite(Led1, HIGH)

else

digitalWrite(Led2, LOW)

Sorry, verify error is below.

error: expected unqualified-id before 'if'

Is hour a variable or a function? Or, in this snippet:

if (hour()>=9 && hour <21)

why does the first use of hour have brackets after it but the second doesn't?

Ups, that fixed but still have verify error masage

if (hour()>=9 && hour() <21)

error: expected unqualified-id before 'if'

Head over to http://snippets-r-us.com for help with your snippets. They're useless here.

Sorry here is full code.

#include <Wire.h>
#include "RTClib.h"
#include <Time.h>
#include <TimeAlarms.h>

RTC_DS1307 RTC;

int Led1 = 2;
int Led2 = 3;

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

if (! RTC.isrunning()) {
Serial.println("RTC dont work!");
}

pinMode(Led1, OUTPUT);
pinMode(Led2, OUTPUT);

if (hour() >= 9 && hour() =< 21)
{
digitalWrite(Led1, HIGH);
}
else
{
digitalWrite(Led2, LOW);

}

Alarm.alarmRepeat(8,30,0, Day);
Alarm.alarmRepeat(20,30,0, Night);

int V1;

void loop() {

DateTime now = RTC.now();

Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();

Alarm.delay(1000);
}

void Night () {

for (int i=0; i<255; i+=1)
{
V1 +1;

analogWrite(Led1,255 - V1);
analogWrite(Led2,0 + V1);
delay(7000);

}

}

void Day () {

for (int i=0; i<255; i+=1)
{
V1 +1;

analogWrite(Led1,0 + V1);
analogWrite(Led2,255 - V1);
delay(7000);

}

if (hour() >= 9 && hour() =< 21)

There are defined comparison operators. You can't just make up your own and hope they are understood. It <=, not =<.

Where does setup() end? You are missing at least one }.

Make that two.

Layout your code ( the IDE gives you a tool to do it with just two clicks - it will help you more that it does us!) and PSOT IN CODE TAGS - THE # not in a "quote".

Mark

and PSOT IN CODE TAGS

I'm pretty sure that code is about as PSOTted as it can be.

Sorry to bother you.

I solved the problem.

Thanks for your help.

Your current problem may be fixed, but there are others that you haven't discovered yet.

For example, code that checks hour() twice may occasionally fail because the checks happen to overlap a change of hour just right. It won't fail often, just enough to drive you quietly crazy. Maybe the occasional failure doesn't concern you.

delay(...) statements are suspect as well, as are print(...) statements in a loop.

Good luck!

vlatx:
Sorry to bother you.

I solved the problem.

Thanks for your help.

You haven't bothered anyone here, so no need to apologize.

It would be very helpful to others if you describe how you solved your problem.

...R

Did you fix this?

  V1 +1;