Looking for this code

Hi, I'm working on my graduation project which is 1-axis solar tracker - self cleaning. A 5V, 1A uni-polar 8 wire stepper motor is used to drive a 100W, 12V solar panel to track the sun. I have the code & it is working fine with 3 LDRs connected to Arduino UNO R3.

Now I'm moving to the next step which is fixing a dc or stepper motor & a small electric water pump to wipe the solar panel. Exactly,, the small electric water pump should spray water for 5 seconds at the same time the wiping motor should run for 15 seconds to wipe the solar panel. They should start at the same time. This operation should perform only once every 24 hours.

How can i write this code.

Thanks,

Use your keyboard ?

Study the "blink without delay" example. It will show you how to keep track on time in a correct way. Start spraying first, and then start wiping (like your car does with the windshield). You don't want to wipe with dry wipers. You can control the spray-pump and the wiper motor with relays. Those are easy to control.

Do not expect someone else to do your homework for you.

You probably have a Real-Time Clock to track the sun. Do you already have code to move the panel back to the east at night? That might be a good time to give them a wipe. Or at midnight.

digitalWrite(pumpPin, HIGH);
digitalWrite(wiperPin, HIGH);
delay(5000);
digitalWrite(pumpPin, LOW);
delay(10000);
digitalWrite(wiperPin, LOW);

No I'm tracking the sun by the 3 LDRs, so by the time of sunrise it will automatically move towards the east. The plan was to give it a wipe before every sunrise every day.

There are a few questions here.

Do you shut down the Arduino for the night in order to minimise power use? If you are anticipating about 1 kWh a day, then the 1 Wh the Arduino takes (from a battery) over 24 hours would not be too arduous, but you might choose to economise on this by sleeping.

In any case, variations on the "blink without delay" principle, which is that you regularly read the interrupt-driven millisecond counter and thereby keep count of seconds, minutes and hours as you loop through the main code, can be used to keep track of day and night. If you sleep during the night, you can have a timer wake it periodically (for very brief periods) to keep an alternate track of time. On this basis, you can determine when it is night-time (no power generated for several hours) and perform your salutary function at the very first sign of power generation thereafter.

Yes,, in order of speaking ideally you are right, but practically 0.036 A for 12 hours as a standby from 12 V, 60 A battery won't make that difference. In day time the battery will be charged from the solar. 0.4 A is required to drive the stepper motor to track the sun for less than a second every 15 min due to the sun movement, I think this will be fine for me.