Nel caso potresti usare la libreria narcoleptic per il delay: ti mette in sleep il processore durante i delay() risparmiando un tot la batteria:
-
https://code.google.com/p/narcoleptic/ Codice:
/*
RC finder
By: Lanz
se il canale della ricevente emmette segnale > mille
non suona, altrimenti o e' spenta e suona o e'
interruttore e suona comunque.
E' previsto ovviamente che arduino abbia alimentazione separata.
Addendum: narcoleptic delay(): https://code.google.com/p/narcoleptic/
*/
#include <Narcoleptic.h>
int ch1;
void setup() {
//Serial.begin(9600);
pinMode(0, INPUT); // Set input pin
}
void loop() {
ch1 = pulseIn(0, HIGH, 25000); // Read the pulse width of
if(ch1<1300){
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
Narcoleptic.delay(1000); // put the MCU to sleep for 1 sec
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
Narcoleptic.delay(1000); // put the MCU to sleep for 1 sec
}
}
__________________
v911 - LadyBird - nQX - SuperCP - HFP80 - HCP80 - HCP100 - Devo 7e MoD - Taranis - Heli-X
Wing Wing Z-84 - Bonsai - M. Sonic - Sonic 64 EDF - S.Kinetic - Rare Bear M. - Walrus - Phoenix 2K - M. DLG - Sbach EPP - Extra 330 - Edge 540T - MX2 EPP 955 - Yak - Reaktor - SCT 1/16