Skip to content

Sleep mode on tiny412 has issues #1144

Answered by MX682X
johnnylingo asked this question in Q&A
Discussion options

You must be logged in to vote

Here is what I would have done. It contains a replacement of the the Interrupt handling, which probably would have worked as is, but attatch interrupt is always evil...

// set up attiny412 to check for button, if power is off check hold for 3 seconds then turn on
// if power is on, turn off
#include <avr/sleep.h>
#include <avr/interrupt.h>
#include <avr/power.h>
volatile bool powerState = false;
volatile bool wakeState = false;
volatile bool returnState = false;
volatile int y = 0;

const int ledPin = 2;  // the number of the LED pin
const int bPin = 0; //button pin
int ledState = LOW;  // ledState used to set the LED

void setup() {
  pinMode(ledPin, OUTPUT);
  //pinMode(bPin, INPUT_PULL…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@MX682X
Comment options

Answer selected by johnnylingo
@johnnylingo
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants