I want 12 leds in the circuit programmed to go around at a certain speed. 17 smd leds in total. What I need to do is for the chase to randomly chose to slow down for 1 second or speed up for 1 second with a respective led come on each time it is chosen. It is using a ATMEL AT89C2051-24PU (DIP-20) microcontroller, 3v battery, 17 leds(12 for chase,3 for rotation, 2 for speed up/down notifier) , 1 switch, 1 piezo. Leds go around at the programmed speeds and clocks 1 rotation notified by an individual led 3 rotations in total. Start of rotation notified by piezo and at the end. How can I do this, can I program into the microcontroller or will I need a different one or two?

Im a novice.


  • \$\begingroup\$ How many LEDs do you want to control? \$\endgroup\$
    – stevenvh
    Commented Aug 1, 2012 at 13:23
  • \$\begingroup\$ Thanks for replying Steven. I've hopefully made it easier to do. With a bit more of the details of inventory. Ive just got a pick it 2 for program but I dont know anything about what it can do. \$\endgroup\$
    – Mr Men
    Commented Aug 1, 2012 at 14:13
  • 2
    \$\begingroup\$ @iliaskafetzakis You have a pickit2 programmer? That's no good. You can only program Microchip microcontrollers (PIC) with that. For Atmel microcontrolles, you'll need another programmer. \$\endgroup\$
    – m.Alin
    Commented Aug 1, 2012 at 14:22
  • \$\begingroup\$ It's a little hard to understand what's being asked here. How to program a microcontroller is a little bit much to put in a single answer. Can you narrow it down a little bit? \$\endgroup\$ Commented Aug 1, 2012 at 14:35
  • \$\begingroup\$ Wow, I've just read the previous version of this question. It's much easier to understand. \$\endgroup\$ Commented Aug 1, 2012 at 14:37

1 Answer 1


You said that you are a novice, Do you have any experience of C or assembly programming. As far as your question concern, your program requirement is not simple.

However i shall guide you.

You may do your work with just one microcontroller, but you need multiplexing technique for this, as your described cntroller has 15 I/Os and you are interfacing 17 LEDs, 1 push button switch and 1 buzzer.

For Buzzer one output is required. For Push button one input is required. For 3 rotation LEDs and 2 Speed LEDs you need 5 outputs For 12 LEDs you may connect all 12 LEDs in 4x3 format, 12 LEDs in 4 rows and 3 coloums, which consumed 7 outputs.

So, Total 14 I/Os are consumed, 1 is still free.

I assumed that you have some basic knowledge of microcontroller programming and its all registers.

You have to make your program in modular form (module: small or a big program) and labeled them according their function name, each function has its own module. Let say LED Chaser function module name may be LED_Chaseer or LED_Chase.

Make one module for Timer function and one for switch and buzzer funcion.

ONE Timer interrupt function, where you are driving all LEDs.

One main function is obviously required for running continously. In this MAIN function, you have to read switch function first than start timer by sending timer function a value. On every timer interrupt drive LEDs as you want. and than increment or decrement timer value for LED Visual change.

From this way you can get your results.

Wish you best of Luck


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.