How can you set time with a software RTC without using "T124535487679"??

Im trying to set the time on the software RTC using the setTime(1,15,0,1,1,10); function
the values in setTime go as follows: setTime(hour,minute,second,month,day,year);
so, setTime(1,15,0,1,1,10); would be 1:15 am 00 seconds, january 1st 2010

Im trying to assign int's to each of the (hour,minute,second,month,day,year) parameters but so far, i can only set the hour. I think it has something to do with Serial.flush(); or while statement but cant figure it out.

here is a snippet of my code:

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

int h;
int m;

Serial.println("Enter Hour: ");
while(Serial.available() == 0){}
h = Serial.read();
delay(500);
Serial.flush();
Serial.println("Enter Minute: ");
while(Serial.available() == 0){}
m = Serial.read();
Serial.print(m);
delay(500);

setTime(h,0,0,1,1,10); // set time to 8:29:40am Jan 1 2010

It's not clear what the exact problem is from your description, but I see a couple of obvious issues. Why do you say you can only set the hour? What happens with the code you posted? Have you tried without the call to flush()? I don't see any value in calling it by the way.

Also you'll need to convert the return values from read() into a number. From memory the read() function returns the ASCII value. Oh and you know that read() returns a single byte right? So if you punch '12' into your serial monitor in response to "Enter Hour:" you'll get back the ASCII code for '1'.

Something like this maybe:

int b1, b2, hours;

b1 = Serial.read();
b2 = Serial.read();
hours = ( ( b1 - '0') * 10 ) + ( b2 - '0' );

Cheers,
G.

Serial.flush(); is a function that is almost never required and almost always destructive, or misused at best, in most normal sketches. If you can't state a specific reason for why and for when to use a flush command, then you probably should not be using it.

Lefty