hi
i want make arduino code set low power. consume 20ma. want reduce it. how it.
################################################################
const int buttonpin = 2;
const int ledpin = 13;
byte ledflag = 0;
byte enableflag = 0;
unsigned long ledtime;
unsigned long flashtime;
const unsigned long flashrate = 100ul;
int buttonstate = 0;
void setup()
{
pinmode(ledpin, output);
pinmode(buttonpin, input_pullup);
}
void loop()
{
buttonstate = digitalread(buttonpin);
if (buttonstate == high && ledflag == 0)
{
digitalwrite(ledpin, high);
ledflag = 1;
enableflag = 1;
ledtime = millis();
flashtime = millis();
}
if (enableflag == 1 && millis() - ledtime <= 4500ul)
{
if (millis() - flashtime >= flashrate)
{
flashtime = millis();
digitalwrite(ledpin, !digitalread(ledpin));
}
}
else
{
enableflag = 0;
digitalwrite(ledpin, low);
}
if (buttonstate == low)
{
ledflag = 0;
enableflag = 0;
digitalwrite(ledpin, low);
}
}
have considered sleep mode?
type "sleep" in search box @ top of page.
good luck.
type "sleep" in search box @ top of page.
good luck.
Arduino Forum > Using Arduino > Programming Questions > how to make arduino nano pro low power
arduino
Comments
Post a Comment