meet 2 Posted March 14, 2014 Share Posted March 14, 2014 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. Quote Link to post Share on other sites
Thorvard 14 Posted March 14, 2014 Share Posted March 14, 2014 Try activating the internal pullup on pin P1.4: pinMode(P1_4, INPUT_PULLUP); and define state as boolean: volatile boolean state = LOW; energia and meet 2 Quote Link to post Share on other sites
meet 2 Posted March 15, 2014 Author Share Posted March 15, 2014 Thanks a lot! Input pullup doesn't mean anything but boolean state made it works. Thorvard 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.