karlwr
Newbie level 4
- Joined
- Nov 14, 2014
- Messages
- 5
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 46
Hi all, I have a Little problem getting my LPC2119 to work as I want it to.
This is a very basic thing that I'm trying to do but I can't get it working
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
!
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
BR
This is a very basic thing that I'm trying to do but I can't get it working
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
!
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 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
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 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 { IOSET1 |=(1<<16); IOCLR1 <=(1<<18); } } }
BR
Last edited by a moderator: