About
LED USING SWITCH
#include<lpc214x.h>
void delay();
void main()
{
PINSEL0 = 0x00000000;
PINSEL1 = 0x00000000;
PINSEL2 = 0x00000000;
IO1DIR |=0XfffffFFF; //Port 1 is now acting as a output pin
IO0DIR = 0x0; //Port 0 is now acting as a input pin
while(1)
{
//Checking 15th pin of Port 0 (Switch 1). If switch is pressed, Pin value will be 0.
if ((IO0PIN & (1<<15)) ==0)
IO1SET |= (1<<16); // (LED1 is glowing)
else
IO1CLR |=(1<<16); // (LED is OFF)
}
}
void delay()
{
unsigned int i;
for(i=0;i<30000;i++);
}