Hello,
I'm trying to minimize the power consumption on my attiny85 as it will be connected to a battery and I found that if you shutdown the ADC and put it to sleep mode it only consumes about 1uA wich is good so I added the following elements to my code:
#include <avr/sleep.h>
#define adc_disable() (ADCSRA &= ~(1<<ADEN)) // disable ADC (before power-off)
#define adc_enable() (ADCSRA |= (1<<ADEN)) // re-enable ADC
void enterSleep(void) // Function that puts the microcontroller to sleep
{
sleep_enable();
sleep_cpu();
}
void setup() {
adc_disable();
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
}
void loop(){
if(mySerial.read() == 'g'){
for(int i = 0;i <= 4;i++){
Do something
}
enterSleep();
}
}
when I send the first 'g' it doe's ok but when I send another 'g' it doesn't respond assuming it's sleeping.
I tried that code on my arduino uno and I dont know what is the problem.
Do I have to wake it up or there is another method to use it?
Thanks for your time.