Jump to content

Search the Community

Showing results for tags 'debounce'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • News
    • Announcements
    • Suggestions
    • New users say Hi!
  • Spotlight!
    • Sponsor Spotlight
    • Sponsor Giveaways
  • Energia
    • Energia - MSP
    • Energia - TivaC/CC3XXX
    • Energia - C2000
    • Energia Libraries
  • MSP Technical Forums
    • General
    • Compilers and IDEs
    • Development Kits
    • Programmers and Debuggers
    • Code vault
    • Projects
    • Booster Packs
    • Energia
  • Tiva-C, Hercules, CCXXXX ARM Technical Forums
    • General
    • SensorTag
    • Tiva-C, Hercules, CC3XXX Launchpad Booster Packs
    • Code Vault
    • Projects
    • Compilers and IDEs
    • Development Kits and Custom Boards
  • Beagle ARM Cortex A8 Technical Forums
    • General
    • Code Snippets and Scripts
    • Cases, Capes and Plugin Boards
    • Projects
  • General Electronics Forum
    • General Electronics
    • Other Microcontrollers
  • Connect
    • Embedded Systems/Test Equipment Deals
    • Buy, Trade and Sell
    • The 43oh Store
    • Community Projects
    • Fireside Chat
  • C2000 Technical Forums
    • General
    • Development Kits
    • Code Vault
    • Projects
    • BoosterPacks

Calendars

There are no results to display.


Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Location


Interests


Sparkfun


Github

Found 1 result

  1. Sorry if this has been asked and answered before, but the results from searches didn't explain the reason not working on my device and code.. Basically trying to do a very simple debounce in an interrupt for an Energia code sketch that paint a 1602 LCD: const int buttonPin = PUSH1; // the number of the pushbutton pin int buttonState; // the current reading from the input pin volatile int lastButtonState = LOW; // the previous reading from the input pin volatile long lastDebounceTime = 0; // the last time the output pin was toggled volatile long debounceDelay = 500; // the debounce time; increase if the output flickers void setup() { ... pinMode(buttonPin, INPUT_PULLUP); attachInterrupt(buttonPin, switchDisplayMode, FALLING); } ... void switchDisplayMode() { int reading = digitalRead(buttonPin); if (reading != lastButtonState) { // reset the debouncing timer lastDebounceTime = millis(); } if ((millis() - lastDebounceTime) > debounceDelay) { // whatever the reading is at, it's been there for longer // than the debounce delay, so take it as the actual current state: buttonState = reading; // start displayMode++; if (displayMode > 5) { displayMode = 0; } // delayMicroseconds(6000000); refreshDisplay(); // end lastButtonState = reading; } } In the above code, debounce did not work all the times, like 3 in 5 times it seem to work, the rest are not. The displayMode variable incremented twice for each button clicked event. The target device is F5529 LP. I have tried the delayMicroseconds which I believed to be irrelevant to the debounce logic if implemented correctly, but that doesn't seem to do the trick either.. Am I doing it wrongly? Any advice will be much appreciated. Thanks in advance.
×
×
  • Create New...