Sleep mode for one day then complete an action!Please Help!

I need the servo to turn downward then wait 500ms then turn back up then go into sleep mode then wake up using the watchdog please help I'm a novice in Arduino and it would be a godsend if someone could make this function I commented out everything that didn't work right now the servo does everything I want it too and it uses a delay to wait a day but it uses way too much power.

It’s an arduino mega 2560 R3

#include <Servo.h>
int servoPin=9;
int servoPos1=0;
int servoPos2=160;
Servo myServo;

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
myServo.attach(servoPin);

//setup watchdog timer
//WDTCSR = (24);//change enable and WDE - also resets
//WDTCSR = (33);//prescalers only - get rid of the WDE and WDCE bit
//WDTCSR |= (1<<6);//enable iterrupt mode

//Disable ADC
//ADCSRA &= ~(1 << 7);
//ENABLE SLEEP
//SMCR |= (1 << 2);//power down mode
//SMCR |= 1;//enable sleep
}

void loop() {
// put your main code here, to run repeatedly:

myServo.write(servoPos1);
delay(5000);
myServo.write(servoPos2);

for(int i=0; i<10800; i++){//gives 24 hours
//BOD DISABLE
//MCUCR |= (3 << 5);//set both BODS and BODSE at the same time
//MCUCR = (MCUCR & ~(1 << 5)) | (1 << 6);//then set the BODS bit and clear the BODSE bit at the same time
//asm volatile("sleep");

delay(86400000);// disable if using watch dog
}
}

Please edit your post to add code tags. Instructions and posting hints are given in the "How to get the best out of the forum" post.

Sleep modes are specific to the Arduino, so identify yours.

Keep in mind putting the processor to sleep won't affect power consumption by servos and other gadgets, and those may be the worst offenders.

It’s an arduino mega 2560 R3 and the servo only runs for about 5 seconds then it’s idle for the rest of the day any more questions just ask thank you for responding to my thread and I’ll look into code tags

Idle, but consuming a significant amount of power. A Pololu power switch solves that problem.

Would I have to physically press the power switch though because it needs to work for months on end without contact and so you don’t think it’s possible just using sleep mode interrupted by watchdog timer

Research the details on the product page.

because it needs to work for months on end without contact

Unlikely to be the case with a DIY project, especially if you are a beginner.

Do you think it could work with ought any extra parts if I outsourced it to someone who knows more than me since I need it to fit in a compact area and right now all it is is the Arduino and a micro servo and it would mess up my design if I added a bread board a lot of wires and an rtc

How accurate does the one -day delay need to be ?

A common trick - if accuracy isn’t precise, would be to use a timer interrupt to wake for a moment, and count the timer events until they reach the desired total time. Your CPU would only be running fo a few milliseconds per day to save power.

It doesn’t have to be accurate at all that’s what I was planning on doing with the watchdog timer but I couldn’t get it to work

If you could describe what your servo is connected to, we may be able to suggest an alternative mechanism that would do the same job but not consume power continuously like your servo would.

Use the LowPower library and start with an example from it.

For more information on how it works, study this excellent tutorial.

It rotates a pvc pipe from up to down to let out dog food

Ok. Does one rotation empty the tube of dog food, or is there enough food for several operations?

Several it hold 300 pounds it’s meant to be industrial sized

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.