I am thinking of building a volume sensor with the arduino.
I want to use this at specific hours. I am going to buy a water flow sensor for the arduino and I already have the code to make it work, but I do not know how to make it start again, at a specific hour.
I know that I can use the delay, to make it repeat constantly, but how can I make it start again at a certain hour?
Please help!
Thanks in advance!
The Arduino does not make for a very accurate clock so you might want to add a Real-Tim Clock (RTC) to your project.
If the Arduino's built in clock is accurate enough for you, just count the minutes as they pass:
unsigned Hour = 0;
unsigned Minute = 0;
unsigned long TimeOfLastMinute = 0;
void loop()
{
unsigned long currentTime = millis();
if (currentTime-TimeOfLastMinute >= 60000UL)
{
Minute++;
TimeOfLastMinute = currentTime;
if (Minute > 59)
{
Minute = 0;
Hour++;
if (Hour > 23)
Hour = 0;
}
}
}
Of course the clock will reset to 0 if the Arduino is reset or power is lost.
If you add a real-time clock module, then, yes, you can make the Arduino do things at specific times. Without a RTC, you'll need some way of telling the Arduino what time it is, and then it can keep track of the time.
Do I need to buy a rtc or is it just made by programming it?
I've searched a bit, and it seems that I have to buy it.
Please tell me how to do this!
Thanks in advance!
Always have a look around first:
http://arduino.cc/playground/Main/InterfacingWithHardware#time
Can I use this:
MCP79410 RTC, Real Time Clock I2C IC, Arduino PIC AVR
instead of the rtc 1307?
Please tell me so I will not buy something that just doesn't work!
Thanks in advance!
Can I use this:
MCP79410 RTC, Real Time Clock I2C IC, Arduino PIC AVR
No. This string of letters is not a suitable substitute for real hardware.
It should work through the I2C interface. Watch out for older chips which have some bugs:
Hi i want to control the flow rate with arduino. I did buy flow meter sensor but if sensor runs over 10 minutes i want to illuminate a led. Have any idea anyone? Thanks
Have any idea anyone?
Yes. Write some code. Make it do what you want.