This mini-project is especially meant for a newbie in Embedded Systems. This project will give you a clear idea of how to think and implement your code in practical life. In this article, we will cover the programming details for LED blinking and how you can code your microcontroller to show different patterns of LED blinking. After learning the logic for LED blinking you can code any microcontroller with the same logic.
- 1 microcontroller 89C52(89S52 will also do)
- 1 potentiometer-10k
- 2 ceramic capacitors-22pF
- 1 switch(button for reset purpose)
- 1 electrolytic capacitor-10uF,25V
- 1 crystal oscillator-11.0592MHz
- 1 resistor-10k
- 8 LED's
- 8 330 ohm resistor
- 2 switches (SPST)
This project is made with the help of Proteus software. If you are unaware of the software you can learn the basics by watching the video tutorial that I recommended in one of my articles.
The connection of the circuit is explained below:
- Port 1 of the microcontroller is used as the input Port
- Port 2 of the microcontroller is used as the output Port
- The LED's are connected to the output of Port 2
- Two switches are connected to the input of Port 1
one switch is connected to the 5th pin of the Port 1 whereas the other switch is connected to the 8th pin of the Port 1
- Other components like the crystal and switch are used for the working of the microcontroller
The programming is done using Keil compiler. The circuit is configured for two modes namely (1) The LED Blinking mode and the (2) Chasing LEd mode.when the switch connected to the 8th pin of the Port 1 is closed , the microcontroller works in the Blinking mode wherein all the LED's glow simultaneously for one second and remain switched off for the other one second and this process continues as long as the microcontroller is receiving the power supply .The blinking LED's are shown below:
When the switch connected to the 5th pin of the micro controller is closed and the switch connected to the 8th pin is open, the micro controller works in the Chasing LED mode i.e. the LED's glow one after the another for a second and looks something like this:
The detail explanation of the coding is done below
Some things that you can try
You can play around with the code to get your own LED pattern. Try using P2=0xAA, then provide a delay of 1 second and put the value of P2 as P2=0X55 and again provide a delay of 1 second. Similarly you can try other patterns and have fun. This way you will be able to develop your skill in programming.