Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!




Hans' All LED code ...
 
Share:
Notifications
Clear all

Hans' All LED code debounce methods

4 Posts
2 Users
0 Likes
203 Views
(@jlpicard)
Active Member
Joined: 4 years ago
Posts: 6
Topic starter  

Hans asked me to post this here.  I made a couple gifts for the grandkids and I used his great code:

Arduino – All LEDStrip effects in one (NeoPixel and FastLED)

Unfortunately, the momentary on push-button switches I purchased electrically "bounced", which caused problems moving through the various effects.  I began by placing this code into his sketch:

void changeEffect() {
  if ((digitalRead (BUTTON) == LOW) and (millis() > 200)) {
    selectedEffect++;
    EEPROM.put(0, selectedEffect);
    asm volatile (” jmp 0″);
  }
}

 

This changes the BUTTON function to look for a LOW instead of high, and adds a slight delay of 200 milliseconds.  This code worked just fine, but I also took a step further and replaced the mechanical pushbutton with one of these:

ALAMSCN 20PCS TTP223 Capacitive Touch Switch Button Sensor Module Self Locking for Arduino

Here's an Amazon link for North American users, or a similar TTP223 capacitive touch button for European users.

These worked great and the switched output is debounced by itself.

(Hans updated the link since the forum did something wonky with it, and added a link for the same kind of buttons in Europe)

This topic was modified 2 months ago 2 times by Hans

   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 10 years ago
Posts: 2359
 

Awesome! Thank you for sharing! 👍 


   
ReplyQuote
(@jlpicard)
Active Member
Joined: 4 years ago
Posts: 6

   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 10 years ago
Posts: 2359
 

Oh wow! Nice! Love the fire effect 👍 😊 


   
ReplyQuote

Like what you see and you'd like to help out? 

The best way to help is of course by assisting others with their questions here in the forum, but you can also help us out in other ways:

- Do your shopping at Amazon, it will not cost you anything extra but may generate a small commission for us,
- send a cup of coffee through PayPal ($5, $10, $20, or custom amount),
- become a Patreon,
- donate BitCoin (BTC), or BitCoinCash (BCH).

Share: