Pages

Thursday, 26 April 2018

ARM-LPC1768-Demonstrate the use of an external interrupt to toggle an LED On/Off

Program:
/* Connections
 * Connect P2.11 to switch(development board)
 * Connect P2.3 to led(development board)
 * When switch is pressed led = ~led
 */

#include <lpc17xx.h> 
#include "ExtInt.h"

/* LED assigned to P2.3, pin number can be changed */
#define    LED    3   

/* Interrupt Handler */
void EINT1_IRQHandler(void)
{
/* Toggle the LED (P2_3) */
GPIO_PinToggle(LED);
}
     
int main()
{
/* Initialize the external interrupt 1 */
ExtInt_Init();

/* Initalize the GPIO pin as output */
GPIO_Init(LED);

/* Enable the EINT1 interrupts */
  NVIC_EnableIRQ(EINT1_IRQn);               

/* Infinite loop */
while(1)
{
// Do nothing
}     
}

Hardware Connection
Connect P2.11 to switch (development board)
Connect P2.3 to led (development board)

Output
When switch is pressed led = ~led

 FOR DETAIL INFORMATION ABOUT ARM CORTEX DEVELOPMENT KIT : CLICK HERE

No comments:

Post a Comment