Power and LCD Backlight
The central needs to "listen" RF all the time so the nodes can decide when sending data is needed. But the LCD Backlight is not needed all the time to we can save 50% of the power by switching it off most of the time.
I use a BlinkPlug as interface. Pressing the green button switches the light on (always on), the red button turns it off. Pushing the red button when off already the light is temporary on for six seconds. Here my code for lightingcontrol:
PortI2C myI2C (1);
LiquidCrystalI2C lcd (myI2C);
BlinkPlug buttons (4);
byte light = 0;
byte alarm = 0;
MilliTimer templight;
void setup() {
templight.set(10000);
lcd.begin(16, 2);
lcd.print("JC.0.1"); }
void loop() {
byte pushed = buttons.pushed();
if (pushed) {
if (pushed & 1){ // green button = light on
light = 1;
}
if (pushed & 2){ // red button = light off
if (light == 1){
light = 0;
}
else { // red button but light already off = temporary light for 6 seconds
templight.set(6000);
}
}
}
if (templight.remaining()==0) // stop timer once finished (without, light is switched on again after 60sec)
templight.set(0);
lcd.setCursor(15, 1); // switch light and print light status in lower right corner of lcd
if (light){
lcd.backlight(); // always on
lcd.print("A");
}
else if (templight.remaining()){
lcd.backlight(); // temp on, print remaining temp time
lcd.print(itoa((templight.remaining()/1000+1), buf, 10));
}
else{
lcd.noBacklight(); // lights off
lcd.print("-");
}
}