 	0 serial rx
 	1 serial tx
 	2 bluetooth status
-  11 connection status led
-  13 power led
+  22 battery warning led
+  23 power /connection status led
 */
 
+// used pin definitions
+#define btStatus 2
+#define batteryLed 22
+#define connectionLed 23
+
+// define led brighness here in percentage
+#define LED_BRIGHTNESS 5
+// for 82-100 ohm series resistor and small 3mm red/green through-hole
+// led, 5 % seems fine.
+#define ledOutputValue 255*LED_BRIGHTNESS/100
+
 // some status variables
-boolean teensyLedStatus = false;
+boolean batteryLow = false;
+byte batteryLedStatus = 0;
+
 boolean btConnected = false;
-boolean lowBattery = false;
 byte connectionLedStatus = 0;
 
-#define btStatus 2
-#define teensyLed 13
-#define connectionLed 11
+
 
 long const int WaitIndicationInterval = 200;
 unsigned long int lastWaitIndicationUpdate = 0;

void runWaitBtIndication() {
  if (millis() > (lastWaitIndicationUpdate + WaitIndicationInterval)) {
    lastWaitIndicationUpdate = millis();
    digitalWriteFast(connectionLed, connectionLedStatus);
    connectionLedStatus = !connectionLedStatus;
  }
}

void runBatteryIndication() {
  // blink status led at known interval when battery is low.
  if(lowBattery) {
    if (millis() > (lastBatteryIndicationUpdate + WaitBatteryInterval)) {
      lastBatteryIndicationUpdate = millis();
      digitalWriteFast(teensyLed, teensyLedStatus);
      teensyLedStatus = !teensyLedStatus;
    }
  }
}


        // there are some spare bits. This uses one of them for battery status reporting.
        // get battery status
        if(bitRead(buttons, 6)) { // bit 6 && 7 are both ones when battery low
          batteryLow = true;
        } else {
          batteryLow = false;
        }
	      Joystick.send_now();
      }
