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 ![]()

