PLEASE HELP! Increment Time and Printing it to Serial Monitor.

Hello All!

I am trying to have an incremented time print each second through the serial port. My seconds are a float because I would like two decimals printed. The original time is set to a random time and date and then from there I would like it to print out the incremented time by one second onto the serial monitor. I have tried searching this forum and googling but can't seem to find an answer that works.

Thanks in advance and here is my code: (p.s. the extra stuff in there is me trying to get it to print whenever the LED is ON, which for now is every second)

#include <SoftwareSerial.h>

 
// set pin numbers:
const int ledPin =  13;      // the number of the LED pin

// Variables will change:
int ledState = LOW;             // ledState used to set the LED

int s_hr = 3;
int s_min = 30;
float s_sec = 2.32;   //Changed from int to float to get two decimal places printed

int day = 24;
int month = 4;
int year = 2014;

// the follow variable is a long because the time, measured in milliseconds,
// will quickly become a bigger number than can be stored in an int.
long interval = 500;           // interval at which to blink (milliseconds), smaller interval equals faster blink

void setup() {
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);

  Serial.begin( 57600 );           //Speed = 57600 bps (baud rate)
  Serial.println( "Start Time Increment" );
}

void loop()
{
   digitalWrite(ledPin, HIGH);   // turn the LED on (HIGH is the voltage level)
   delay(1);               // wait for a millisecond
   digitalWrite(ledPin, LOW);    // turn the LED off by making the voltage LOW
   delay(999);               // wait for a second
    
   if (ledState == HIGH)                 //added this 'if' statement so that if the LED is on then it would print to the serial port

    if(s_hr < 10)             //added these if statements to get a leading zero printed
      Serial.print('0');
    Serial.print( s_hr );   //must output 2 characters
    if(s_min < 10)
      Serial.print('0');   
    Serial.print( s_min );  //must output 2 characters
    Serial.print( s_sec );  //must output 2.2 format
    Serial.print( "," );
    if(day < 10)
      Serial.print('0');
    Serial.print( day );   //2 chars
    Serial.print( "," );
    if(month < 10)
      Serial.print('0');
    Serial.print( month );  //2 chars
    Serial.print( "," );
    Serial.println( year );  //4 chars
   
  }

I figured it out!!!

I tried to delete this post since I figured it out but apparently I can't do that. Oh well, thanks anyways![/size]

No need to delete anything, but it may be helpful to others if you give details of your solution.

...R

I'm guessing that it has to do with setting ledState to LOW, never changing it, and then testing against HIGH.

And a bunch of missing curly braces.