Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

Using interrupt

$
0
0

I'm new on energia, and just trying to use interrupt with an external stimulus. I'm using PIR sensor on P1_4 to fire the interrupt flag and light the red led on launchpad but my code doesn't work;

//PIR input on port P1_4
volatile int state = LOW;

void setup()
{
 
  pinMode(P1_4, INPUT);
  pinMode(RED_LED, OUTPUT);
  attachInterrupt(P1_4, A, RISING);
}

void loop()
{
  digitalWrite(RED_LED, state);
}

void A(){
  state = !state;
  
}

Also, I want to add LPM on this code but I'm not sure where to add it. 

Thanks in advance.


Viewing all articles
Browse latest Browse all 2077

Trending Articles