DIY Microcontroller Based Step-up and Step-down LED Drivers

It’s possible to design your own switching LED drivers using a microcontroller as its PWM source.

Some of my LED lamps and bike lights use microcontroller based LED drivers. The microcontroller used include ATtiny85 and ATtiny84.

With a lower supply voltage, you might find your energy savings significant when using a switching LED driver. If you need to power a 3.2V white LED with LiFePO4 cells which are 3.2V each, you likely need two cells for stability. With a step-down driver, the efficiency is around 85%. With a current limiting resistor, the efficiency falls to 50% with more waste heat!

With a microcontroller, there’s more flexibility. You can adjust the driver’s feedback voltage and drive current, and add more features.

With an adjustable feedback voltage, you can decrease the drop-out voltage of the driver and you don’t have to change resistors to adjust the drive current.

With an adjustable drive current, you can increase the lumens per watt rating of your LEDs when dimming. At a lower drive current, a high end LED can have 200 LPW. Near its maximum current, it can fall to 100 LPW even with PWM dimming. If you installed a lower current rating LED, you can update the code to lower the current.

The features that you might add to the driver include button control, brightness adjustment, potentiometer control, battery monitor, maximum duty cycle, memory of settings, and sleep mode.

When designing a boost driver, it’s important to have fuses and overvoltage protection in case of errors in your program or your output disconnects. I’ve often burned my components when designing boost drivers.

It’s recommended that the transistor has a high Vds and power rating. TO-220 packages usually are preferable to TO-92 or SOT23 packages because they can handle more power.

I find that oscilloscopes make troubleshooting easier. I tend to keep the circuits simple and my circuit boards custom made so that troubleshooting is easier.

I might experiment with even higher voltages because it can drive more LEDs with fewer drivers. If you’re using a 12V power supply, you can use a single driver to power 20 red or yellow LEDs, or 15 white LEDs! You might be able to drive even more depending on your components’ ratings. With a step-down driver, you can power only four red or yellow LEDs or three LEDs from a single driver.

Possible project ideas include bike lights, flashlights, desk lamps, work lights, and grow lights.

If you’re not comfortable with designing boost LED drivers, you can try buck drivers. There’s no need to worry about overvoltage and there’s less risk of overcurrent. To prevent damaging your LEDs while testing, you can connect them to a current limiting resistor. You can still use fewer drivers and have more power by selecting higher current LEDs, or connecting more cells in series.

On Instructables, there are microcontroller based LED driver projects.


DIY Lipo Battery Holder for Puncture Protection

While Lipo batteries have a high power to weight ratio, they can catch fire or explode if abused. That’s why I built a holder for it.

The materials were:

  • ABS enclosure
  • 3S 1500 mAh Lipo battery
  • Foam
  • Bubble Wrap
  • Velcro straps

The enclosure can protect it from sharp objects. They’ll be installed into my bike basket to power accessories.

Lamp Wired to the 78.125 kHz ATtiny 85 Boost LED Driver

The custom LED driver was wired to a string of 6 – 365 nm UV LEDs with a total of around 15 watts.

Here’s a video of the lamp being used. It’s not very bright because it emitted only a small amount of visible light.

Here are the pictures for the lamp construction. A fan wasn’t installed so the second switch wasn’t used.

This lamp was used to test for the UV protection of the goggles. If the highlighter ink doesn’t fluoresce, it means that UV is blocked. You can try sunscreens too.

When using a UV lamp, it’s important to wear UV protection goggles even though our eyes are insensitive to its wavelengths.

Developing My Interest in Electronics

It took at least 10 years for electronics to become my hobby.

During childhood, I had some experience with electronics. The components that I used include LEDs, light bulbs, batteries, and wires. I also built other projects on electronics project lab kits.

My difficulties include burning out LEDs, not getting a DIY thermocouple to work, and not understanding the circuits in the labs. I didn’t have much other experience for a while.

More than 10 years later, I got back into electronics by using LEDs. I’m interested in LEDs because they’re energy efficient, have high colour purities, mercury free, long lasting, and have lots of other applications such as road safety. I think they’re also attractive visually. I learned about their circuits, their drivers, and their applications from Google search. I shopped for components both online and locally.

I like designing circuits because you get to include the features you want, and learn about them. The projects I made include LED circuits, dimmers, bike lights, sunrise simulators, flashlights, and lamps. Some of them were documented on

From designing circuits, I learned about other components such as transistors, voltage regulators, and 555 timers.

Since I’m into electronics, I studied electronics courses at BCIT. The courses covered troubleshooting, AC, DC, electronics components, microcontrollers, IC’s, and electronic circuits. The circuits we’ve built include amplifiers, LED displays, and timers.

I think working with circuits and developing my interest was very important for my success in the courses. If I took them a few years earlier, I doubt that I would have done as well.

Over time, from doing more research, I’ve upgraded my circuits. The bike lights were upgraded from a single pattern to more features including different patterns, and buttons from using microcontrollers instead of 555 timers or an on/off switch. The LED circuits were more efficient. The products became more compact from using custom made circuit boards and SMT components instead of prototyping boards. The products became lighter and more powerful from using Li-ion batteries instead of NiMH batteries.

In the future, I might try the Raspberry Pi, making multi-layer circuit boards, e-bikes, drones, wireless connectivity for the Arduino, 3D printers, other battery chemistries, other tools, and other components.

Bike Light That may Improve Cycling (Features List)

I’m working on a bike light for improving cycling. Its features include:

  • Low beam brightness controlled by speed for longer battery life
  • Inactivity timer for improving battery life
  • Daytime running lights
  • Side visibility LEDs
  • Turn signal lights
  • Brake light with brake status LED
  • LED strips
  • Tip over alarm for alerting road users of a crash
  • Horn
  • Bell
  • Low power modes
  • Adjustable modes for different riding conditions and power levels
  • Easy to locate switches
  • Li-ion batteries

What do you think? Do you have any suggestions?

APR18650M1A Batteries Internal Resistance Measurement

The APR18650M1A LiFePO4 batteries are high powered and low cost. They have a rated capacity of 1100 mAh, a rated voltage of 3.3V, and a rated current of 30A. 10 pieces cost $36 on eBay. I measured their internal resistance with the SKYRC B6AC V2 Charger.



Enter a caption The battery pack was soldered to power and charge balance connectors. It’s very important to get their polarities correct or you’ll damage the charger.

I bought them because they’re lighter than the 1.3Ah 12V SLA battery used for the car horns on my bicycle, quite safe, and long life.

Possible applications of the batteries include battery pack rebuilding, power tools, flashlights, battery backups, and e-bikes. Note that they’re 3.3V which is lower than the 3.7V cells commonly used in electronics. They also need a charge voltage of 3.6V instead of 4.2V.

To test them, I installed them into a custom built 4 cell 18650 battery pack and connected it to the charger.

The battery pack’s total internal resistance was 268mR. If you draw 30 amps, the pack voltage should drop to 5.16V.
Individual cell internal resistances being displayed.
Individual cell voltages being displayed.
Battery total voltage being displayed.

Compared to other LiFePO4 batteries bought from DealeXtreme, the APR18650M1A batteries have a low internal resistance. Those from DX have an internal resistance of about 0.18 ohm, or up to three times higher. If your applications are high current such as electric vehicles and power tools, you’ll need a lower internal resistance.

I have tested the batteries with a pair of car horns. With two horns, they should draw 10 amps which means the battery pack voltage drops to 10 to 11V. Unlike other 18650 batteries I used before, the horns didn’t click.

If you’re interested in a battery that’s lightweight, high powered, safe, and long lasting, I would recommend the APR18650M1A batteries or something similar.