BOD_OFF code example

Example 1: BOD_OFF

LowPower.powerDown(SLEEP_1HOUR, ADC_OFF, BOD_OFF);

Example 2: BOD_OFF

#include "LowPower.h"
void setup()
{ 
// No setup is required for this library 
} 
void loop() 
{ 
// Sleep for 8 s with ADC module and BOD module off 
LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); 
// Do something here 
// Example: read sensor, log data, transmit data 
}

Example 3: BOD_OFF

SleepyPi.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF); 
or       SleepyPi.powerSave(SLEEP_FOREVER, ADC_OFF, BOD_OFF, TIMER2_OFF); 
or       SleepyPi.powerStandby(SLEEP_FOREVER, ADC_OFF, BOD_OFF); 
or       SleepyPi.powerExtStandby(SLEEP_FOREVER, ADC_OFF, BOD_OFF, TIMER2_OFF);
or       SleepyPi.adcNoiseReduction(SLEEP_FOREVER, ADC_OFF, TIMER2_OFF);
or       SleepyPi.idle(SLEEP_FOREVER, ADC_OFF,TIMER2_OFF,TIMER1_OFF,TIMER0_OFF,SPI_OFF, USART0_OFF,TWI_OFF);

Example 4: BOD_OFF

radio.sleep();  // Put radio to sleep 	sleep.pwrDownMode();	sleep.sleepDelay(SleepTime);

Example 5: BOD_OFF

// 4 hours = 60x60x4 = 14400 s
// 14400 s / 8 s = 1800
unsigned int sleepCounter;
for (sleepCounter = 1800; sleepCounter > 0; sleepCounter--)
{
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);  
}

Example 6: BOD_OFF

radio.Sleep();var = 0;while(var < 10){  // do something 10 times  var++;  // put the processor to sleep for 8 seconds  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);}

Example 7: BOD_OFF

pinMode(LEDPIN, OUTPUT);digitalWrite(LEDPIN,HIGH);LowPower.powerDown(SLEEP_60MS, ADC_CONTROL_OFF, BOD_OFF);digitalWrite(LEDPIN,LOW);

Example 8: BOD_OFF

radio.Sleep();LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);

Example 9: BOD_OFF

#ifndef LowPower_h
#define LowPower_h

#include "Arduino.h"

enum period_t
{
	SLEEP_15MS,
	SLEEP_30MS,
	SLEEP_60MS,
	SLEEP_120MS,
	SLEEP_250MS,
	SLEEP_500MS,
	SLEEP_1S,
	SLEEP_2S,
	SLEEP_4S,
	SLEEP_8S,
	SLEEP_FOREVER
};

enum bod_t
{
	BOD_OFF,
	BOD_ON
};

enum adc_t
{
	ADC_OFF,
	ADC_ON
};

enum timer5_t
{
	TIMER5_OFF,
	TIMER5_ON
};

enum timer4_t
{
	TIMER4_OFF,
	TIMER4_ON
};

enum timer3_t
{
	TIMER3_OFF,
	TIMER3_ON
};

enum timer2_t
{
	TIMER2_OFF,
	TIMER2_ON
};

enum timer1_t
{
	TIMER1_OFF,
	TIMER1_ON
};

enum timer0_t
{
	TIMER0_OFF,
	TIMER0_ON
};

enum spi_t
{
	SPI_OFF,
	SPI_ON
};

enum usart0_t
{
	USART0_OFF,
	USART0_ON
};

enum usart1_t
{
	USART1_OFF,
	USART1_ON
};

enum usart2_t
{
	USART2_OFF,
	USART2_ON
};

enum usart3_t
{
	USART3_OFF,
	USART3_ON
};

enum twi_t
{
	TWI_OFF,
	TWI_ON
};

enum usb_t
{
	USB_OFF,
	USB_ON
};

enum idle_t
{
	IDLE_0,
	IDLE_1,
	IDLE_2
};

class LowPowerClass
{
	public:
		#if defined (__AVR__)

			#if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega168__) || defined (__AVR_ATmega168P__) || defined (__AVR_ATmega88__)
				void	idle(period_t period, adc_t adc, timer2_t timer2,
						     timer1_t timer1, timer0_t timer0, spi_t spi,
					         usart0_t usart0, twi_t twi);
			#elif defined __AVR_ATmega644P__ || defined (__AVR_ATmega1284P__)
				void	idle(period_t period, adc_t adc, timer2_t timer2,
							 timer1_t timer1, timer0_t timer0, spi_t spi,
							 usart1_t usart1, usart0_t usart0, twi_t twi);
			#elif defined __AVR_ATmega2560__
				void	idle(period_t period, adc_t adc, timer5_t timer5,
							 timer4_t timer4, timer3_t timer3, timer2_t timer2,
							 timer1_t timer1, timer0_t timer0, spi_t spi,
							 usart3_t usart3, usart2_t usart2, usart1_t usart1,
							 usart0_t usart0, twi_t twi);
			#elif defined __AVR_ATmega256RFR2__
				void	idle(period_t period, adc_t adc, timer5_t timer5,
									 timer4_t timer4, timer3_t timer3, timer2_t timer2,
				   				 timer1_t timer1, timer0_t timer0, spi_t spi,
						       usart1_t usart1,
									 usart0_t usart0, twi_t twi);
			#elif defined __AVR_ATmega32U4__
				void	idle(period_t period, adc_t adc, timer4_t timer4,
				             timer3_t timer3, timer1_t timer1, timer0_t timer0,
				             spi_t spi, usart1_t usart1, twi_t twi, usb_t usb);
			#else
				#error "Please ensure chosen MCU is either 88, 168, 168P, 328P, 32U4, 2560 or 256RFR2."
			#endif
			void	adcNoiseReduction(period_t period, adc_t adc, timer2_t timer2) __attribute__((optimize("-O1")));
			void	powerDown(period_t period, adc_t adc, bod_t bod) __attribute__((optimize("-O1")));
			void	powerSave(period_t period, adc_t adc, bod_t bod, timer2_t timer2) __attribute__((optimize("-O1")));
			void	powerStandby(period_t period, adc_t adc, bod_t bod) __attribute__((optimize("-O1")));
			void	powerExtStandby(period_t period, adc_t adc, bod_t bod, timer2_t timer2) __attribute__((optimize("-O1")));

		#elif defined (__arm__)

			#if defined (__SAMD21G18A__)
				void	idle(idle_t idleMode);
				void	standby();
			#else
				#error "Please ensure chosen MCU is ATSAMD21G18A."
			#endif

		#else

			#error "Processor architecture is not supported."

		#endif
};

extern LowPowerClass LowPower;
#endif

Example 10: BOD_OFF

#include "LowPower.h"

const int wakeUpPin = 3;

void wakeUp()
{
}

void setup()
{
   pinMode(LED_BUILTIN, OUTPUT);
   pinMode(wakeUpPin, INPUT_PULLUP);
   attachInterrupt(digitalPinToInterrupt(wakeUpPin), wakeUp, FALLING);
}

void loop()
{
   LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
   digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}

Tags:

Misc Example