Content originally posted in LPCWare by Karthik C on Wed Jul 08 06:42:25 MST 2015
hi, I'm facing a problem with taking an input from push button
my code is like when you press the button led should get on
but with out pressing the button led is getting on
even i checked in keil peripherals it going inside the if condition without the pin high
please help me out with this
here is my code
#include "lpc17xx.h"
void delay(uint32_t c)
{
while(c>0)
c--;
}
int main(void)
{
SystemInit();
LPC_GPIO0->FIODIR |=(1<<4);
LPC_GPIO2->FIODIR &= ~(1<<10);
while(1)
{
if(((LPC_GPIO2->FIOPIN >> 10) & 1) == 1)
{
LPC_GPIO0->FIOSET=0x00000010;
delay(10000);
}
else
{
LPC_GPIO0->FIOCLR=0x00000010;
delay(10000);
}
}
}