# Using a microcontroller to make a series of LEDs blink one after the other

This may seem like a nooby question, but I have a cycle light with 5 LEDs:

* * * * *

And it has a button, which when pressed hase different modes:

• 1st press: all LEDs blink together
• 2nd press: all LEDs stay lit
• 3rd press: 1st LED goes on, then it goes of and 2nd LED goes on, so on till 5th, then 4th LED again...
• 4th press: it turns off.

I was wondering how to make this. I can make a simple circuit so that all are on. I was thinking, that something like an 8-pin microcontroller can be used to make them blink together, but for them to blink independently, I guess I will have to use a microcontroller with enough pins so that each LED has it's own?

But my bike light is pretty small and I don't think it is running an AtMega32 or something. How does it work?

• It uses a very small MCU. – Ignacio Vazquez-Abrams Aug 16 '15 at 19:53
• There are smaller and cheaper microcontrollers than ATmega32. Also there are chips specifically made for bike lights, the number of devices produced is so large that is more efficient to have an application specific IC (or ASIC). – jippie Aug 16 '15 at 19:53
• An 8 bit shift register with a slow clock and a handful of diodes could be used to achieve this - no need for a whole microcontroller. It would be a more interesting project to see if you can build this from "discrete" components rather than throwing a micro controller at it. Especially if you are a "noob" by your own admission. Challenge yourself a bit... – Floris Aug 17 '15 at 0:45

## 2 Answers

With 5 LEDs, 1 button, and 2 pins for power this is a perfect match for an 8-pin micro-controller. The hobby-friendly DIP-8 package would easily fit in your bike light, but the manufacturer probably used a cheaper un-packaged chip directly bonded to the PCB and put a blob of black goo on it. This manufacturing method is sometimes called "chip on board".

• +1 Chances are they used a COB ASIC die costing a few pennies in the bike light rather than double the entire cost of the product by using a PIC, but for small quantities, a micro such as a PIC12F series is perfect (and you'd never be able to use a bare die without a lot of equipment and expertise, even if you could find a supplier who would sell them). – Spehro Pefhany Aug 16 '15 at 22:09
• @Spehro: I've used a bare die PIC on a volume product. They are certainly available, but don't make sense for small volumes. If you're not going to make a few 100k or 1M, it's probably not worth it. You don't need a lot of special equipment, you use a contract manufacturer who already has COB capability. It definitely is cheaper in high volumes. – Olin Lathrop Aug 16 '15 at 22:27
• @OlinLathrop Thanks- there does not seem to be much on Microchip's site on bare die options for PICs. I've been looking into wire bonding for microwave circuits where quantities can be very limited. – Spehro Pefhany Aug 16 '15 at 22:49
• @Spehro: Bare die is one of those things you have to have a conversation with your sales guy about. At those volumes you should anyway, whether using COB or not. Prices for high volumes are a negotiation, not something quoted from a price list. If you're using more than 100k Microchip products, of any mix, per year, get to know your sales guy. – Olin Lathrop Aug 16 '15 at 22:57
• But can an 8 pin individually control the 5 LEDs separately? Because when the 3rd one is on, the others are off. So is it that 2 pins for power, 1 for button, and the other 5 used for each LED? – poiasd Aug 17 '15 at 9:07

You will need a 8 pin microcontroller. There are many cheap microcontrollers available. You can use PIC microcontroller. Its cheap and programmings are simple for led blinking and easily available on Internet.

• The number of bit is not the point. The ATmega the OP menations is an 8-bit UC too. The size is more related to the number of pins. – Wouter van Ooijen Aug 16 '15 at 21:19
• Sorry, i mistyped. It should be pin. Thanx. – user5230499 Aug 16 '15 at 21:20