|
编译和烧录下述休眠代码
#include <avr/sleep.h>
void setup ()
{
pinMode(LED_BUILTIN, OUTPUT);
int count;
for (count = 0; count < 5; ++count)
{
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200); // wait for 200ms
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(200); // wait for 200ms
}
// disable ADC
ADCSRA = 0;
set_sleep_mode (SLEEP_MODE_PWR_DOWN);
noInterrupts (); // timed sequence follows
sleep_enable();
// turn off brown-out enable in software
MCUCR = bit (BODS) | bit (BODSE);
MCUCR = bit (BODS);
interrupts (); // guarantees next instruction executed
sleep_cpu (); // sleep within 3 clock cycles of above
} // end of setup
void loop () { }
|
|