Multiple Output on 1 LED problem

hi guys.. as you can see in the subject is that I'm having a trouble using a single output LED to run using 2 different loops.. i'm trying to have a HIGH output on an LED1 once the comparison of my circuit1(real time clock - saves a running time in military setup) and the clock on my laptop.

here is the part of the code which should light up LED1 once the time is equal from the RTC to the time on my laptop.

if(((now.hour()==HOUR1)&&(now.minute()==MINUTE1)))
{

if(flag == 1)
{
lcd.setCursor(9,1);
lcd.print(" Med 1 ");
lcd.println();
digitalWrite(LED,HIGH);
delay(10000); //delay for 25sec
lcd.clear(); //Delete the Display of Medicine after the buzzer
delay(1000); //Delay time for the lcd.clear function
flag = 0; // clear flag
delay(1000);
}
else {

digitalWrite(LED,LOW);
}
}

and here is the part of the code which I use to light up again the same LED when the arduino compares the time in the RTC and in my laptop

if(((now.hour()==HOUR4)&&(now.minute()==MINUTE4)))
{
if(flag4 == 1)
{
lcd.setCursor(9,1);
lcd.print(" Med 1 ");
lcd.println();
digitalWrite(LED2,HIGH);
delay(5000); //delay for 1sec
lcd.clear(); //Delete the Display of Medicine after the buzzer
delay(1000); //Delay time for the lcd.clear function
flag4 = 0; // clear flag
delay(1000);
}
else {
digitalWrite(LED,LOW);
}
}
}

The first part of the comparing code is working and shows the result I want which lights up the LED1 for 10 seconds and then turns it off after. but on the 2nd part of the code when the time comparing is equal. i cannot light up the SAME LED1. do you know guys why is it like that? here is the copy of the whole code:

#include <Wire.h>
#include "RTClib.h"
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// Create RTC object
RTC_DS1307 RTC;

// Assign LED to digital pin 13
const int LED = 8;
const int LED2 = 9;
const int LED3 = 10;

// Flag for entering LED routines
uint8_t flag = 1;
uint8_t flag2 = 1;
uint8_t flag3 = 1;
uint8_t flag4 = 1;
uint8_t flagbuzz = 1; //flag comparison for Buzzer

// Set alarm to activate two times a day
byte HOUR1 = 19, MINUTE1 = 54;
byte HOUR2 = 19, MINUTE2 = 55;
byte HOUR3 = 19, MINUTE3 = 56;
byte HOUR4 = 19, MINUTE4 = 57;

void setup ()
{

pinMode(LED,OUTPUT); // LED pin as output
digitalWrite(LED,LOW); // Turn off LED by default

pinMode(LED2,OUTPUT); // LED pin as output
digitalWrite(LED2,LOW); // Turn off LED by default

pinMode(LED3,OUTPUT); // LED pin as output
digitalWrite(LED3,LOW); // Turn off LED by default

Serial.begin(57600); // Initialize serial & set baudrate

Wire.begin(); // Initialize I2C 2 wires interface
RTC.begin(); // Initialize DS1307 RTC chip
lcd.begin(16, 2); // Initialize LCD Interface

if (! RTC.isrunning()) // If RTC is not running, set the time
{
lcd.print("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
RTC.adjust(DateTime(DATE, TIME));
}
}

void loop ()
{
// Read current time from RTC chip
DateTime now = RTC.now();
// Send current time to serial for debugging
// Using the lcd.print(); it display the former Serail.print to the LiquidCrystal lcd.setCursor(3,0);
// Date Display code

lcd.setCursor(3,0);
lcd.print(now.year(),DEC);
lcd.print('/');
lcd.print(now.month(),DEC);
lcd.print('/');
lcd.print(now.day(),DEC);
lcd.print(' ');

// Time Display code
lcd.setCursor(0,1);
lcd.print(now.hour(),DEC);
lcd.print(':');
lcd.print(now.minute(),DEC);
lcd.print(':');
lcd.print(now.second(),DEC);
lcd.println();
lcd.setCursor(8,1);
lcd.print(" ");

//Start of codes for alarm and Medicine number number display
// led red
if(((now.hour()==HOUR1)&&(now.minute()==MINUTE1)))
{

if(flag == 1)
{
lcd.setCursor(9,1);
lcd.print(" Med 1 ");
lcd.println();
digitalWrite(LED,HIGH);
delay(10000); //delay for 25sec
lcd.clear(); //Delete the Display of Medicine after the buzzer
delay(1000); //Delay time for the lcd.clear function
flag = 0; // clear flag
delay(1000);
}
else {

digitalWrite(LED,LOW);
}
}

// led yellow
if(((now.hour()==HOUR2)&&(now.minute()==MINUTE2)))
{
if(flag2 == 1)
{
lcd.setCursor(9,1);
lcd.print(" Med 2 ");
lcd.println();
digitalWrite(LED2,HIGH);
delay(5000); //delay for 1sec
lcd.clear(); //Delete the Display of Medicine after the buzzer
delay(1000); //Delay time for the lcd.clear function
flag2 = 0; // clear flag
delay(1000);
}
else
{
digitalWrite(LED2,LOW);
}
}
if(((now.hour()==HOUR3)&&(now.minute()==MINUTE3)))
{
if(flag3 == 1)
{
lcd.setCursor(9,1);
lcd.print(" Med 3 ");
lcd.println();
digitalWrite(LED3,HIGH);
delay(5000); //delay for 1sec
lcd.clear(); //Delete the Display of Medicine after the buzzer
delay(1000); //Delay time for the lcd.clear function
flag3 = 0; // clear flag
delay(1000);
}
else
{
digitalWrite(LED3,LOW);
}

if(((now.hour()==HOUR4)&&(now.minute()==MINUTE4)))
{
if(flag4 == 1)
{
lcd.setCursor(9,1);
lcd.print(" Med 1 ");
lcd.println();
digitalWrite(LED,HIGH);
delay(5000); //delay for 1sec
lcd.clear(); //Delete the Display of Medicine after the buzzer
delay(1000); //Delay time for the lcd.clear function
flag4 = 0; // clear flag
delay(1000);
}
else {
digitalWrite(LED,LOW);
}

}

}
} //Final Closing Bracket for Void loop

Now with code tags, please.

hi guys.. as you can see in the subject is that I'm having a trouble using a single output LED to run using 2 different loops.. i'm trying to have a HIGH output on an LED1 once the comparison of my circuit1(real time clock - saves a running time in military setup) and the clock on my laptop.

here is the part of the code which should light up LED1 once the time is equal from the RTC to the time on my laptop.

if(((now.hour()==HOUR1)&&(now.minute()==MINUTE1)))
{

if(flag == 1)
{
lcd.setCursor(9,1);
lcd.print(" Med 1 ");
lcd.println();
digitalWrite(LED,HIGH);
delay(10000); //delay for 25sec
lcd.clear(); //Delete the Display of Medicine after the buzzer
delay(1000); //Delay time for the lcd.clear function
flag = 0; // clear flag
delay(1000);
}
else {

digitalWrite(LED,LOW);
}
}

and here is the part of the code which I use to light up again the same LED when the arduino compares the time in the RTC and in my laptop

if(((now.hour()==HOUR4)&&(now.minute()==MINUTE4)))
{
if(flag4 == 1)
{
lcd.setCursor(9,1);
lcd.print(" Med 1 ");
lcd.println();
digitalWrite(LED2,HIGH);
delay(5000); //delay for 1sec
lcd.clear(); //Delete the Display of Medicine after the buzzer
delay(1000); //Delay time for the lcd.clear function
flag4 = 0; // clear flag
delay(1000);
}
else {
digitalWrite(LED,LOW);
}
}
}

The first part of the comparing code is working and shows the result I want which lights up the LED1 for 10 seconds and then turns it off after. but on the 2nd part of the code when the time comparing is equal. i cannot light up the SAME LED1. do you know guys why is it like that? here is the copy of the whole code:

#include <Wire.h>
#include "RTClib.h"
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// Create RTC object
RTC_DS1307 RTC;

// Assign LED to digital pin 13
const int LED = 8;
const int LED2 = 9;
const int LED3 = 10;

// Flag for entering LED routines
uint8_t flag = 1;
uint8_t flag2 = 1;
uint8_t flag3 = 1;
uint8_t flag4 = 1;
uint8_t flagbuzz = 1; //flag comparison for Buzzer

// Set alarm to activate two times a day
byte HOUR1 = 19, MINUTE1 = 54;
byte HOUR2 = 19, MINUTE2 = 55;
byte HOUR3 = 19, MINUTE3 = 56;
byte HOUR4 = 19, MINUTE4 = 57;

void setup ()
{

pinMode(LED,OUTPUT); // LED pin as output
digitalWrite(LED,LOW); // Turn off LED by default

pinMode(LED2,OUTPUT); // LED pin as output
digitalWrite(LED2,LOW); // Turn off LED by default

pinMode(LED3,OUTPUT); // LED pin as output
digitalWrite(LED3,LOW); // Turn off LED by default

Serial.begin(57600); // Initialize serial & set baudrate

Wire.begin(); // Initialize I2C 2 wires interface
RTC.begin(); // Initialize DS1307 RTC chip
lcd.begin(16, 2); // Initialize LCD Interface

if (! RTC.isrunning()) // If RTC is not running, set the time
{
lcd.print("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
RTC.adjust(DateTime(DATE, TIME));
}
}

void loop ()
{
// Read current time from RTC chip
DateTime now = RTC.now();
// Send current time to serial for debugging
// Using the lcd.print(); it display the former Serail.print to the LiquidCrystal lcd.setCursor(3,0);
// Date Display code

lcd.setCursor(3,0);
lcd.print(now.year(),DEC);
lcd.print('/');
lcd.print(now.month(),DEC);
lcd.print('/');
lcd.print(now.day(),DEC);
lcd.print(' ');

// Time Display code
lcd.setCursor(0,1);
lcd.print(now.hour(),DEC);
lcd.print(':');
lcd.print(now.minute(),DEC);
lcd.print(':');
lcd.print(now.second(),DEC);
lcd.println();
lcd.setCursor(8,1);
lcd.print(" ");

//Start of codes for alarm and Medicine number number display
// led red

if(((now.hour()==HOUR1)&&(now.minute()==MINUTE1)))
{

if(flag == 1)
{
lcd.setCursor(9,1);
lcd.print(" Med 1 ");
lcd.println();
digitalWrite(LED,HIGH);
delay(10000); //delay for 25sec
lcd.clear(); //Delete the Display of Medicine after the buzzer
delay(1000); //Delay time for the lcd.clear function
flag = 0; // clear flag
delay(1000);
}
else {

digitalWrite(LED,LOW);
}
}

// led yellow
if(((now.hour()==HOUR2)&&(now.minute()==MINUTE2)))
{
if(flag2 == 1)
{
lcd.setCursor(9,1);
lcd.print(" Med 2 ");
lcd.println();
digitalWrite(LED2,HIGH);
delay(5000); //delay for 1sec
lcd.clear(); //Delete the Display of Medicine after the buzzer
delay(1000); //Delay time for the lcd.clear function
flag2 = 0; // clear flag
delay(1000);
}
else
{
digitalWrite(LED2,LOW);
}
}
if(((now.hour()==HOUR3)&&(now.minute()==MINUTE3)))
{
if(flag3 == 1)
{
lcd.setCursor(9,1);
lcd.print(" Med 3 ");
lcd.println();
digitalWrite(LED3,HIGH);
delay(5000); //delay for 1sec
lcd.clear(); //Delete the Display of Medicine after the buzzer
delay(1000); //Delay time for the lcd.clear function
flag3 = 0; // clear flag
delay(1000);
}
else
{
digitalWrite(LED3,LOW);
}

if(((now.hour()==HOUR4)&&(now.minute()==MINUTE4)))
{
if(flag4 == 1)
{
lcd.setCursor(9,1);
lcd.print(" Med 1 ");
lcd.println();
digitalWrite(LED,HIGH);
delay(5000); //delay for 1sec
lcd.clear(); //Delete the Display of Medicine after the buzzer
delay(1000); //Delay time for the lcd.clear function
flag4 = 0; // clear flag
delay(1000);
}
else {
digitalWrite(LED,LOW);
}

}

}
} //Final Closing Bracket for Void loop

Code, not quote tags, please.

Something like this:

if(((now.hour()==HOUR1)&&(now.minute()==MINUTE1)))
{

if(flag == 1)
{
lcd.setCursor(9,1);
lcd.print(" Med 1 ");
lcd.println();
digitalWrite(LED,HIGH);
delay(10000); //delay for 25sec 
lcd.clear(); //Delete the Display of Medicine after the buzzer
delay(1000); //Delay time for the lcd.clear function
flag = 0; // clear flag 
delay(1000);
}
else {

digitalWrite(LED,LOW);
}
}

and here is the part of the code which I use to light up again the same LED when the arduino compares the time in the RTC and in my laptop

if(((now.hour()==HOUR4)&&(now.minute()==MINUTE4)))
{ 
if(flag4 == 1)
{
lcd.setCursor(9,1);
lcd.print(" Med 1 ");
lcd.println();
digitalWrite(LED2,HIGH); 
delay(5000); //delay for 1sec 
lcd.clear(); //Delete the Display of Medicine after the buzzer
delay(1000); //Delay time for the lcd.clear function
flag4 = 0; // clear flag 
delay(1000); 
} 
else {
digitalWrite(LED,LOW);
}
}
}

The first part of the comparing code is working and shows the result I want which lights up the LED1 for 10 seconds and then turns it off after. but on the 2nd part of the code when the time comparing is equal. i cannot light up the SAME LED1. do you know guys why is it like that? here is the copy of the whole code:

#include <Wire.h>
#include "RTClib.h"
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// Create RTC object
RTC_DS1307 RTC;


// Assign LED to digital pin 13
const int LED = 8;
const int LED2 = 9;
const int LED3 = 10;


// Flag for entering LED routines
uint8_t flag = 1; 
uint8_t flag2 = 1;
uint8_t flag3 = 1;
uint8_t flag4 = 1;
uint8_t flagbuzz = 1; //flag comparison for Buzzer

// Set alarm to activate two times a day
byte HOUR1 = 19, MINUTE1 = 54; 
byte HOUR2 = 19, MINUTE2 = 55;
byte HOUR3 = 19, MINUTE3 = 56;
byte HOUR4 = 19, MINUTE4 = 57;


void setup ()
{ 

pinMode(LED,OUTPUT); // LED pin as output
digitalWrite(LED,LOW); // Turn off LED by default

pinMode(LED2,OUTPUT); // LED pin as output
digitalWrite(LED2,LOW); // Turn off LED by default

pinMode(LED3,OUTPUT); // LED pin as output
digitalWrite(LED3,LOW); // Turn off LED by default


Serial.begin(57600); // Initialize serial & set baudrate

Wire.begin(); // Initialize I2C 2 wires interface
RTC.begin(); // Initialize DS1307 RTC chip
lcd.begin(16, 2); // Initialize LCD Interface

if (! RTC.isrunning()) // If RTC is not running, set the time
{
lcd.print("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
RTC.adjust(DateTime(__DATE__, __TIME__));
}
}

void loop ()
{
// Read current time from RTC chip
DateTime now = RTC.now();
// Send current time to serial for debugging
// Using the lcd.print(); it display the former Serail.print to the LiquidCrystal lcd.setCursor(3,0);
// Date Display code

lcd.setCursor(3,0);
lcd.print(now.year(),DEC);
lcd.print('/');
lcd.print(now.month(),DEC);
lcd.print('/');
lcd.print(now.day(),DEC);
lcd.print(' ');

// Time Display code
lcd.setCursor(0,1);
lcd.print(now.hour(),DEC);
lcd.print(':');
lcd.print(now.minute(),DEC);
lcd.print(':');
lcd.print(now.second(),DEC);
lcd.println();
lcd.setCursor(8,1);
lcd.print(" ");


//Start of codes for alarm and Medicine number number display
// led red
if(((now.hour()==HOUR1)&&(now.minute()==MINUTE1)))
{

if(flag == 1)
{
lcd.setCursor(9,1);
lcd.print(" Med 1 ");
lcd.println();
digitalWrite(LED,HIGH);
delay(10000); //delay for 25sec 
lcd.clear(); //Delete the Display of Medicine after the buzzer
delay(1000); //Delay time for the lcd.clear function
flag = 0; // clear flag 
delay(1000);
}
else {

digitalWrite(LED,LOW);
}
}

// led yellow
if(((now.hour()==HOUR2)&&(now.minute()==MINUTE2)))
{
if(flag2 == 1)
{
lcd.setCursor(9,1);
lcd.print(" Med 2 ");
lcd.println();
digitalWrite(LED2,HIGH); 
delay(5000); //delay for 1sec
lcd.clear(); //Delete the Display of Medicine after the buzzer
delay(1000); //Delay time for the lcd.clear function
flag2 = 0; // clear flag 
delay(1000);
}
else
{
digitalWrite(LED2,LOW);
}
}
if(((now.hour()==HOUR3)&&(now.minute()==MINUTE3)))
{ 
if(flag3 == 1)
{
lcd.setCursor(9,1);
lcd.print(" Med 3 ");
lcd.println();
digitalWrite(LED3,HIGH); 
delay(5000); //delay for 1sec 
lcd.clear(); //Delete the Display of Medicine after the buzzer
delay(1000); //Delay time for the lcd.clear function
flag3 = 0; // clear flag 
delay(1000); 
} 
else
{
digitalWrite(LED3,LOW);
}


if(((now.hour()==HOUR4)&&(now.minute()==MINUTE4)))
{ 
if(flag4 == 1)
{
lcd.setCursor(9,1);
lcd.print(" Med 1 ");
lcd.println();
digitalWrite(LED,HIGH); 
delay(5000); //delay for 1sec 
lcd.clear(); //Delete the Display of Medicine after the buzzer
delay(1000); //Delay time for the lcd.clear function
flag4 = 0; // clear flag 
delay(1000); 
} 
else {
digitalWrite(LED,LOW);
}


}


}
} //Final Closing Bracket for Void loop