Skip to content

Instantly share code, notes, and snippets.

@amatus
Created June 10, 2017 17:43
Show Gist options
  • Save amatus/1645dc64b21936f4b01bf5aa364577b0 to your computer and use it in GitHub Desktop.
Save amatus/1645dc64b21936f4b01bf5aa364577b0 to your computer and use it in GitHub Desktop.
#include <avr/io.h>
#include <avr/sleep.h>
void main()
{
static char state __attribute__ ((section (".noinit")));
DDRB |= (1 << PB2);
if (state)
{
PORTB |= (1 << PB2);
}
else
{
PORTB &= ~(1 << PB2);
}
state = !state;
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
sleep_cpu();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment