LED interfacing with 8051 microcontroller

///LED interfacing with 8051 microcontroller

LED interfacing with 8051 microcontroller

A microcontroller, being an integrated circuit with a processor, contains support devices like program memory, data memory, I/O ports and serial communication interface integrated together. Since all the required support devices are available with the microcontroller, external interfacing of devices is not required.

One of the most popular microcontrollers is Intel 8051. It belongs to the MCS-51 family of Intel microcontrollers. Many companies later adopted the MCS-51 core to develop their own microcontrollers and all these devices could be operated with the MCS-51 instruction sets. The basic difference between these devices is in the size of the memory or in the presence of an ADC or DAC.

Being the most popular microcontroller, Intel 8051 is used in many days to day applications. It can be found in a vehicle’s music system, in an automatic door, in clock rooms to automate the systems and various other common applications. AT89S51 is a microcontroller coming from the family of 8051 microcontrollers. This chapter deals with how AT89S51 is successfully used in an LED blinking application.

LED Blinking-AT89S51

LED blinking is the most basic project with a microcontroller to see a physical output. One can understand the concept of input-output configurations of the general-purpose I/O port in a microcontroller with the simple LED blinking project. The LEDs are simple electronic display units available. This tutorial will explain the method of interfacing LED with 8051 microcontrollers and to develop a c code for blinking the same.

The AT89S51 microcontroller has 4 general purposes I/O ports which can be configured as input or output. Configuring the port pins as output, the state of the port pins can be controlled in firmware either high or low. When the port is configured as input, reading the pins will read the voltage state of the pins.We need to configure the port pins as output for a led blinking process.

Interfacing LED with Microcontroller Pin

interfacing led

The above image is the simple way of interfacing an LED with a microcontroller. The anode is connected to the microcontroller and cathode is connected to ground through a resistor. When the voltage at the controller pin is high the LED will be turned ON and when the voltage is low the LED will be turned off.

Firmware

The beginning of the code should include header file reg51.h which is common for 80C51 controllers. By default, the ports of 8051 microcontrollers are configured as the output.

In the main function, the PORT in which LEDs are connected is loaded with 0x00 and 0xFF with a small delay in between. This part of the code is enclosed within an infinite loop for the continuous execution of the program.

The delay function at the end creates a nominal delay in blinking the LEDs. The accurate value of time delay could be calculated with the known value of instruction execution time but is not done here since it is beyond the scope of this article. Each time when this function is called in main a delay is generated.

The delay function should be declared at the top before the main.

Circuit Diagram

LED blinking AT89S51

Here is the circuit diagram of the AT89S51 interfaced 8 LEDs to Port3 of the Microcontroller. All the LEDs are driven through resistors for limiting current. In this microcontroller, pin source current is limited to 10mA per pin (please refer datasheet, IOL). So even if the resistor is not provided with LED, there will not be any damage to the LEDs.

DON’T MISS OUT UPDATES!
Be the first to get latest updates and exclusive content straight to your email inbox.
Stay Updated
Subscribe, it is quick.
We hate spam too. Give it a try, you can unsubscribe anytime.
Spread the love, share this

Leave A Comment

DON’T MISS OUT UPDATES!
Be the first to get latest updates and exclusive content straight to your email inbox.
Stay Updated
Subscribe, it is quick.
We hate spam too. Give it a try, you can unsubscribe anytime.
close-link
25% OFF - OpenLabPro Course
Use Coupon: CRS25UL

 
8051 Microcontroller Primer
Want to learn indepth programming, peripheral interfacing and driver development?
close-link
Launched: IoT online Course - 25% Off when you complete your order today.
Checkout Now
close-image

Subscribe To our Email Newsletter

Be the first to get latest updates and exclusive content straight to your email inbox.
Send me Tutorials and Guides
close-link