Introduction: Switch Interface With LPC2148

About: i am an electronics hobbyist.

In this article we will learn how to interface the switch to the LPC2148 microcontroller board.We will see the output by adding a led to the LPC2148 board.

Step 1: LP2148 Program for Switch Interface

Connect the a Switch at port 1.16 and LED to the port 0.10 . Connect the a Pull up resistor to the pin Port 0.16.

Step 2: Program:

#include<lpc214x.h>

int main(void)

{

IO1DIR = ~(0x00010000); //configure the input port at port 1.16

IO0DIR =(0x00000400); //configure the output port at port 0.10

while(1)

{

if(IO1PIN & (0x00010000)) //condition for open circuit

{

IO0CLR = (0x00000400); //turn off the led that is at port 0.10

}

else

{

IO0SET= (0x00000400); //turn on the led that is at port 0.10

}

}

return 0;

}

Step 3: Code: