8 LEDs concept:
You can connect 8 LEDs in series with one of the port of 8051 micro-controller. The connection of 8 LEDs are done to teach beginner basic concept of 8051 microcontroller and its interfacing. Any beginner can start with 8 LEDs interfacing and then, he should go further after analyzing and performing on this circuit.Usually, you will get inbuilt circuit of 8 LEDs with microcontroller to Port P2 in your trainer kit. There is available of small student kit in which microcontroller with all its peripherals like crystal oscillator, capacitor, array resistors are built around it and there is also available of 8 LEDs circuit so that beginner can learn about the basic concept. I also learnt on this kit and got my concept clear easily.
Interfacing:
Above circuit diagram shows the connection of 8 LEDs connected to Port P! of 8051. You can use the same Blink program as depicted earlier to write code for 8 LEDs and blink them individually.
By coding you can do different pattern on these 8 LEDs like Blinking of LEDs, Current raiser, Indicator etc. can be performed according to the coding you will do. Perform these programs your own to get command on coding on embedded C in 8051 and simulate the program in Keil µvision 3.
Code:
1. Blink All 8-LEds#include "REG52.h" long int i; void main() { P2=255; // All 8 LEDs ON by decimal number 255; you can also define any number based on binary number for(i=0;i<=9000;i++); // delay should be according to processing speed so that you can see blink P2=0; // OFF all 8 LEDs for(i=0;i<=9000;i++); // delay }
2. Dancing/Alternative LED
#include "REG52.h" long int i; void main() { P2=oxAA; for(i=0;i<=9000;i++); // delay should be according to processing speed so that you can see blink P2=0x55; for(i=0;i<=9000;i++); // delay }
Comments
Post a Comment