Hi all, I have a Little problem getting my LPC2119 to work as I want it to.
Im running a ET-ARM et-arm stamp lpc2119 with GNU arm compiler in µVision3
Im trying to interface a push button with 2LEDs. Using one LED works but not 2.
The compiler does not complain or give me an error.
Here is the code that works, a push button to p0.7 and a LED to p1.18
!
include <LPC21xx.H> // LPC2119 MPU Register
int main(void)
{
PINSEL2 &= ~0x0000000C; // Makesure GPIO1.16-1.31 = GPIO Function,
PINSEL0 &= ~0x0000C000; //GPIO P0.7,
IODIR1 |=(1<<18); // GPIO 1.18 as output
IODIR0 &=~((1<<7)); // Set GPIO0.7 AS input
while(1) // Loop Continue
{
if(!(IOPIN0 & (1<<7))) // When button is pressed
{
IOSET1 |=(1<<18);
}
else
{
IOCLR1 =(1<<18);
}
Here is the code that does not work, 2 LEDs on p1.16 and p1.18, and the push button on p0.7
Im trying to set that when the button is pressed LED1 on and LED2 off, when button not pressed then LED2 on and LED2 off but it only works as Before with one LED turning on and off, the second LED never turns off.!! :(. What is it that I’m missing
include <LPC21xx.H> // LPC2119 MPU Register
int main(void)
{
PINSEL2 &= ~0x0000000C; // Makesure GPIO1.16-1.31 = GPIO Function,
PINSEL0 &= ~0x0000C000; //GPIO P0.7,
IODIR1 |=((1<<16)|(1<<18)); // GPIO p1.18 and p1.16 as output
IODIR0 &=~((1<<7)); // Set GPIO0.7 AS input
while(1) // Loop Continue
{
if(!(IOPIN0 & (1<<7))) // When button is pressed
{
IOSET1 |=(1<<18);
IOCLR1 =(1<<16);
}
else
{
IOCLR1 =(1<<16);
IOCLR1 =(1<<18);
}
}
}