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

[Solved] Hans' All LED code debounce methods

4 Posts
2 Users
0 Reactions
1,125 Views
(@jlpicard)
Active Member
Joined: 5 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)


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2728
 

Awesome! Thank you for sharing! 👍 


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

   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2728
 

Oh wow! Nice! Love the fire effect 👍 😊 


   
ReplyQuote
Share: