Count no. of cycles.

Greetings Everybody!!!!
Hope everyone is doing good.

I have tried an automatic irrigation system using the Arduino and a moisture sensor. I would like to know the number of times the pump has been activated. Is there a program for such an application, to count the no. of times the pump has been activated. This is definitely a piece-a-cake issue but I am very new to programming and not very good either. Could you please guide me in the right direction?

Thanking you

Regards and Best Wishes

If your Arduino program turns on the pump then just add a line of code to increment a variable every time the pump is turned on. Something like

pumpCount ++;

If you need to remember the value if the Arduino shuts down then you would need to write the data to the Arduino's EEPROM memory. Just be aware that an EEPROM memory location has a finite number of write cycles (100,000 IIRC)


And remember, don't increment WHILE the condition is true, increment when the condition GOES true.

In the IDE: File/examples/digital/statechangedetection

I would use the SD Shield and write your "Log" to it instead of the EEPROM.