One way to save power is to change the frequency the chip runs at
@@#include <io.h>
...
/*
lpDelay(quarterSeconds) - Low Power Delay. Drops the system clock
to its lowest setting and sleeps for 256*quarterSeconds milliseconds.
/
int lpDelay(int quarterSeconds) {
int oldClkPr = CLKPR; // save old system clock prescale
CLKPR = 0x80; // Tell the AtMega we want to change the system clock
CLKPR = 0x08; // 1/256 prescaler = 60KHz for a 16MHz crystal
delay(quarterSeconds); // since the clock is slowed way down, delay(n) now acts like delay(n*256)
CLKPR = 0x80; // Tell the AtMega we want to change the system clock
CLKPR = oldClkPr; // Restore old system clock prescale
We care about the privacy and personal data of our users.
To continue, please give us your consent:
Please confirm that you have read the privacy policy
Thank you for subscribing!
Curious to learn more?
Are you also a teacher, student, or professional that loves using Arduino in your day-to-day activities?
Then keep up-to-date with either our STEM or Professional monthly newsletters.
Arduino weekly newsletter (already subscribed)
Educators can benefit from the ever growing tech that shapes our environment through fun cool projects.
Why not awe your boss with highly innovative ways to help keep your enterprise connected at no extra cost?
Arduino Survey
We'd like to get to know you little better.
Please help us improve by answering this super short optional survey.