Nisarg 0 Posted January 20, 2014 Share Posted January 20, 2014 Hey there, there is an error on the site in the example of attachInterrupt function.the page: http://energia.nu/AttachInterrupt.html Tested the code on my MSP430G2 Launchpad. The correct code should be: volatile int state = HIGH; volatile int flag = HIGH; int count = 0; void setup() { Serial.begin(9600); pinMode(GREEN_LED, OUTPUT); digitalWrite(GREEN_LED, state); pinMode(PUSH2, INPUT_PULLUP); //The correction attachInterrupt(PUSH2, blink, FALLING); // Interrupt is fired whenever button is pressed } void loop() { digitalWrite(GREEN_LED, state); //LED starts ON if(flag) { count++; Serial.println(count); flag = LOW; } } void blink() { state = !state; flag = HIGH; } Quote Link to post Share on other sites
roadrunner84 466 Posted January 20, 2014 Share Posted January 20, 2014 Either it already got fixed, or you accessed an other version of the code than I did. Quote Link to post Share on other sites
energia 485 Posted January 20, 2014 Share Posted January 20, 2014 It was corrected on energia.nu but the reference page that ships with Energia has not been corrected. This page was probably missed when syncing things. Will get it synced for the next release. Quote Link to post Share on other sites
Nisarg 0 Posted January 20, 2014 Author Share Posted January 20, 2014 It was corrected on energia.nu but the reference page that ships with Energia has not been corrected. This page was probably missed when syncing things. Will get it synced for the next release. Yeah! I was using the reference docs when I noticed it. Did not notice on the site. Thanks! Quote Link to post Share on other sites
petesoper 0 Posted January 23, 2016 Share Posted January 23, 2016 It's almost exactly two years since the correction above was posted. I was looking for a place to post the same correction just now and found this thread. I just filed an issue on the Energia GitHub. Quote Link to post Share on other sites
energia 485 Posted January 25, 2016 Share Posted January 25, 2016 I just posted this reply to the issue on github: @@petesoper thanks for the report. I thought about this and from a h/w point of view the example is correct. The assumption is that an external pull-up resistor is provided. I think the real issue is that the documentation does not mention a pull-up at all. What I will do is to fix the documentation mentioning an external/internal pull-up and then also add the pinMode(, INPUT_PULLUP); call to the Sketch but comment out with the comment that it should be uncommented IF there is no external pull-up. Robert 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.