Code Help

I am measuring the discharge from a battery using a hall sensor.
I need to have the time elapsed since the battery started to discharge at a specific rate
So if the battery has been discharging at 0-5amps i need an event to occur at 240Seconds... if at 6-10amps then event occurs at 120sec and so on... I am already counting seconds using now() .
How can i best implement this... syntax is not an issue if someone can just get me started on this...

When it starts record the time in a variable. At any other point subtract that from the current time and you get the elapsed time.

Sounds easier than done...

The first time the condition is met I record the time.How do I ensure the next loop doesnt overwrite the time with the current time because the condition is still met.I'll need another variable for it...??

anirudhashish:
Sounds easier than done...

The first time the condition is met I record the time.How do I ensure the next loop doesnt overwrite the time with the current time because the condition is still met.I'll need another variable for it...??

Yes. You'll need another variable, probably a boolean, to keep track of whether or not it has already started. Or maybe you could simply use the fact that the start time has been set. It's hard to help more than that without details on your project. Start writing your code and if you get stuck come back and post what you have and ask for help.

If you're just trying to integrate current to count coulombs, you're going about it in an unusual way.

I modified Adafruit's power meter code here to count coulombs -> http://forum.arduino.cc/index.php?topic=388269.msg2676091#msg2676091

That's how you typically see it done: periodically measure the current then sum current * period.