My LED mod for Adafruit Powerboost 1000c
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

My LED mod for Adafruit Powerboost 1000c

by wilykit on Thu Jun 10, 2021 1:38 am

Powerboost 1000c is a nice device that can power device and charge battery at the same time. But the built in LED may become hidden if you install it inside something like an old game handheld system. I wanted to be able to see the LED but minimize the number of holes or sizes of them when mounting external LED.

I found some 2mm bicolor LED to use and whipped up this code that works on ATTiny85 (could use 13 if you have one!)

Code: Select all | TOGGLE FULL SIZE
void setup() {
  pinMode(0, INPUT);                  // charging check, pin 5 of ATTiny85
  pinMode(1, INPUT);                  // done check, pin 6 of ATTiny85
  pinMode(2, INPUT);                  // low battery check pin 7 of ATTiny85
  pinMode(3, OUTPUT);                 // red LED, pin 2 of ATTiny85
  pinMode(4, OUTPUT);                 // green LED, pin 3 of ATTiny85  both on should produce orange/yellow light
}                                     // pin 1 is reset, pin 4 and 8 is GND and VCC

// LEDs are common anode, red and green through current limiting resistor to ATTiny85

void loop() {
  if (digitalRead(2) == LOW) {        // low battery signal, turn on red only
    digitalWrite(3, LOW);
    digitalWrite(4, HIGH);
  } else if (digitalRead(1) == LOW) { // charging is done status, turn on green only
    digitalWrite(3, HIGH);
    digitalWrite(4, LOW);
  } else if (digitalRead(0) == LOW) { // charging in progress, turn on both LEDs
    digitalWrite(3, !digitalRead(3)); // fake PWM, was too orange/red as is
    digitalWrite(4, LOW);
  } else {                            // LED off, not plugged in and not powered on.
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);

I am using a 2mm common anode R/G LED (as mentioned earlier) and it will be tied into Adafruit Powerboost 1000c since the onboard LEDs will not be visible when I install it into my portable game console. I wanted to move those LED, make it work on a single bulb and small so 2mm R/G LED is the end. Since the Powerboost 1000c has 3 LEDs, converting them into 2 LEDs by using original red (low battery) and green (charging done) as they were and making orange from combining red/green on original yellow charging LED.

When I did the original code, the red/green combined appeared reddish-orange and somewhat hard to see from pure red so I faked PWM on red lead to reduce its brightness by half, it appears more orange/yellow and easier to see. I don't have a datasheet on this specific LED, it is an old stock as no one regularly makes 2mm bicolor LEDs so I don't know if red and green has close spec or if green has slightly higher requirement than red. I supposed I could change the resistor to something a bit lower for green or higher for red.

I coded the priority using if / else so if I am charging and the battery was low, it wouldn't try to flip-flop between low and charging. If it's low, it lights up red and skips the rest of if statements. And when the battery's not low and not charging, the LED stays off.

Total code (with unnecessary options like bootloader, milis(), and brownout all disabled, LTO enabled) was 478 bytes.

Posts: 5
Joined: Mon Mar 12, 2018 10:54 pm

Please be positive and constructive with your questions and comments.