0% found this document useful (0 votes)
147 views

LED (Light Emitting Diodes) : LPC2148 LPC2148 Development Board

The document discusses interfacing a light emitting diode (LED) to a microcontroller. It shows how to connect the anode and cathode of an LED to a microcontroller pin using a resistor. It then provides code to blink LEDs connected to an LPC2148 microcontroller development board by turning the LEDs on and off in a loop. The code uses port pins on the LPC2148 and delays to achieve the blinking effect. Compiling and debugging the code is discussed, along with using Flash Magic to download the hex file to the microcontroller.

Uploaded by

ECGaurav Kamath
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
147 views

LED (Light Emitting Diodes) : LPC2148 LPC2148 Development Board

The document discusses interfacing a light emitting diode (LED) to a microcontroller. It shows how to connect the anode and cathode of an LED to a microcontroller pin using a resistor. It then provides code to blink LEDs connected to an LPC2148 microcontroller development board by turning the LEDs on and off in a loop. The code uses port pins on the LPC2148 and delays to achieve the blinking effect. Compiling and debugging the code is discussed, along with using Flash Magic to download the hex file to the microcontroller.

Uploaded by

ECGaurav Kamath
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

LED (Light Emitting Diodes)

Light Emitting Diodes (LED) is the most commonly used components, usually for displaying pins
digital states.

Interfacing LED

Fig. 1 shows how to interface the LED to microcontroller. As you can see the Anode is connected
through a resistor to GND & the Cathode is connected to the Microcontroller pin. So when the Port
Pin is HIGH the LED is OFF & when the Port Pin is LOW the LED is turned ON.

Fig. 1 Interfacing LED to


Microcontroller

Interfacing LED with LPC2148

Flash a LED using the LPC2148 Development Board. It works by turning ON a LED & then turning
it OFF & then looping back to START. However, the operating speed of the microcontroller is very
high so the flashing frequency will also be very fast to be detected by human eye.

The ARM7 LPC2148 Development Board has eight numbers of point LEDs, connected with I/O
Port lines (P1.16 – P1.23) to make port pins high.

Pin Assignment with LPC2148


Circuit Diagram to Interface LED with LPC2148

Source Code

The Interfacing LED with LPC2148 program is very simple and straight forward, that uses a delay
procedure loop based software delay. In C programs you cannot be sure of delay, because it depends
on compiler how it optimizes the loops as soon as you make changes in the options the delay changes.

C Program to switch ON and OFF LED using LPC2148

**********************************************************************************
*****

Title : Program to Blink LEDs

**********************************************************************************
****

#include // Define LPC2148 Header File


void delay(int x);
void main()
{
PINSEL1 = 0x00000000; // Define port lines as GPIO
IO0DIR = 0x00FF0000; // Define P0.16 – P0.23 as O/P
IO0PIN= 0x00000000; // Define P0.16 – P0.23 as zero
while(1) // Loop forever
{
IOSET0= 0x00FF0000; // Turn ON P1.16 – P1.23 .
delay(2000);
IOCLR0= 0x00FF0000; // Turn OFF P1.16 – P1.23
delay(2000);
}
}
void delay(int x)
{
unsigned int k,l;
for(k = x;k > 0;k--)
for(l = 0;l < x;l++);
}

To compile the above C code you need the KEIL software. They must be properly set up and a project
with correct settings must be created in order to compile the code. To compile the above code, the C
file must be added to the project.

In KEIL, you want to develop or debug the project without any hardware setup. You must compile the
code for generating HEX file. In debugging Mode, you want to check the port output
without LPC2148 Development Board.

The Flash Magic software is used to download the hex file into your microcontroller IC LPC2148
through UART0.

You might also like