Attiny85 Sleep Mode

Hello,
I'm working on a new projet powered by lithium batteries so I try to lower the consumption of my Attiny85.
So I wanted to make something simple for starting : a led blinking and when I press the button (high) for more than 1seconde I enter in sleep mode and when I press again the Attiny85 wakes up and the led turns on. But nothing happens..

#include <avr/io.h>
#include <avr/wdt.h>
#include <avr/sleep.h>

volatile uint8_t wdt_count;
int led = 3; 
int button = 4; 

void setup() {
  ADCSRA &= ~_BV(ADEN);  // ADC OFF (4mA less)
  ACSR  |= _BV(ACD);     // Analog OFF (0,05mA less)
  set_sleep_mode(SLEEP_MODE_PWR_DOWN); 
  wdt_count = 255; //  watchdog initialization
  pinMode(led, OUTPUT); 
  pinMode(button, INPUT_PULLUP);
  attachInterrupt(0, wakeup, RISING); // pin 4 for wakeup
}

void loop() {
  if (digitalRead(button) == HIGH) {
    delay(1000); // wait for long press
    if (digitalRead(button) == HIGH) {
      delay(50); 
      digitalWrite(led, LOW); // Turn off led
      sleep_enable(); // power down mode
      sleep_cpu(); 
    }
  } else {
    digitalWrite(led, HIGH);
    delay(250); 
    digitalWrite(led, LOW);
    delay(250); 
  }
}

void wakeup() {
  sleep_disable(); 
  digitalWrite(led, HIGH); 
}

thanks in advance for the help :slight_smile:

Pin 4 is GND. Use INT0, PB2 or 7. For the true programming nerds, you can change int for byte.

There's no pin 0. Use the variable button

Also, mum (Arduino) recommends this:

For the other code, I'll let others in. :sunglasses:

Went through more than one edit of this one, sorry for eventual confusion.

Hello, thanks for the reply.
by Pin4 I mean PB4, by pin 3 I mean PB3 and the attiny understands it.
So now with this : (digitalPinToInterrupt(4), wakeup, RISING);
it's working, enters in sleep mode and led turns off. But impossible to wake up the attiny :confused:

ATTiny 85s only hardware interrupt pin is PB2 / INT0 / 7....

/Also :confused:

Here's the pinout:

EDIT: Sorry, INT0 seems to be out of the picture, see this:

If you enable pin change interrupts, a change of state on any input pin can wake the processor from sleep.

INT0 cannot be used to wake the processor on RISING if it is in power down sleep mode. Use CHANGE instead.