Hey Guys !
I am working on a small led display project. I am using an ATtiny 4313-PU. I have a code to send the unit to sleep. I wood like the unit to come back to life when I press a button on the INT0 interrupt pin.
Do you have any idea what I am doing wrong ?
Thanks for your help !!
#include <avr/interrupt.h>
#include <avr/sleep.h>
#include <avr/power.h>
#include <avr/io.h>
uint8_t led = 0;
void setup() {
Â
 pinMode(7, OUTPUT);
 pinMode(6, OUTPUT);
Â
 cli();
 GIMSK |= (1<<INT0); //activate INT0 interupt
 MCUCR |= (0<<ISC00); //falling edge
 MCUCR |= (1<<ISC01);
 sei();
}
void loop() {
 delay(1000);
 sleepNow();
}
void sleepNow()
{
  // Choose our preferred sleep mode:
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  // Set sleep enable (SE) bit:
  digitalWrite(6, LOW); // turn the LED on (HIGH is the voltage level)
  //delay(1000);
  sleep_enable();
  // Put the device to sleep:
  sleep_mode();
  // Upon waking up, sketch continues from this point.
  sleep_disable();
  digitalWrite(6, HIGH);  // turn the LED off by making the voltage LOW
  delay(5000);
}
ISR(INT0_vect)
{
 static unsigned long last_interrupt_time = 0;
 unsigned long interrupt_time = millis();
 // If interrupts come faster than 200ms, assume it's a bounce and ignore
 //if (interrupt_time - last_interrupt_time > 200)
 //{
  cli();
  led = !led;
  digitalWrite(7, led);
  delay(1000);
  sei();
//}
last_interrupt_time = interrupt_time;
}
INT0 pin is pulled down