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.
Thanks
Answer
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
No comments:
Post a Comment