# Debounce button and delays

**URL:** <https://forum.arduino.cc/t/debounce-button-and-delays/902601>\
**Category:** Programming\
**Created:** [September 6, 2021, 12:33am UTC](https://forum.arduino.cc/t/debounce-button-and-delays/902601 "2021-09-06T00:33:29Z")\
**Posts on this page:** 1\
**Showing post:** 118

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [September 13, 2021, 6:47pm UTC](https://forum.arduino.cc/t/debounce-button-and-delays/902601/118 "2021-09-13T18:47:57Z")

</div>

* * *

I am a hardware person.

* * *

Going through the sketch and mastering what’s there should give you a good skill set for writing future code.

* * *

> [@tarabas05](#):
>
> much stronger project would be a new idea I have,much needed at work and for bad neighborhoods: person recognition with camera, and track people within a given geo fence

I know nothing about this.

* * *

* * *

Homework for you:

Arduino links of interest.

How to use this forum:

> [@How to get the best out of this forum](https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/681310):
>
> Welcome to the Arduino forum! A guide explaining how to get the best out of this forum is available at the link below. Please read it:

Getting started:  
[https://www.arduino.cc/en/Guide](https://www.arduino.cc/en/Guide)

Listing of downloadable 'Arduino PDFs' :  
Either Google \>\>\>- - - - \> arduino filetype: pdf  
Or  
[https://www.google.ca/search?q=arduino+filetype%3A+pdf&rlz=1C9BKJA\_enCA739CA739&oq=arduino+filetype%3A+pdf&aqs=chrome..69i57j69i65.1385j0j7&hl=en-US&sourceid=chrome-mobile&ie=UTF-8](https://www.google.ca/search?q=arduino+filetype%3A+pdf&rlz=1C9BKJA_enCA739CA739&oq=arduino+filetype%3A+pdf&aqs=chrome..69i57j69i65.1385j0j7&hl=en-US&sourceid=chrome-mobile&ie=UTF-8)

Listing of downloadable 'C++ PDFs' :  
Either Google \>\>\>- - - - \> C++ filetype: pdf  
Or  
[https://www.google.ca/search?q=c%2B%2B+filetype%3A+pdf&rlz=1C9BKJA\_enCA739CA739&oq=c%2B%2B+filetype%3A+pdf&aqs=chrome..69i57.22790j0j7&hl=en-US&sourceid=chrome-mobile&ie=UTF-8](https://www.google.ca/search?q=c%2B%2B+filetype%3A+pdf&rlz=1C9BKJA_enCA739CA739&oq=c%2B%2B+filetype%3A+pdf&aqs=chrome..69i57.22790j0j7&hl=en-US&sourceid=chrome-mobile&ie=UTF-8)

Arduino cheat sheet:  
[https://dlnmh9ip6v2uc.cloudfront.net/learn/materials/8/Arduino\_Cheat\_Sheet.pdf](https://dlnmh9ip6v2uc.cloudfront.net/learn/materials/8/Arduino_Cheat_Sheet.pdf)

Watch these:  
Arduino programming syntax:  
[https://m.youtube.com/watch?v=CbJHL\_P5RJ8](https://m.youtube.com/watch?v=CbJHL_P5RJ8)

Arduino arithmetic operators:  
[https://m.youtube.com/watch?v=UUx0\_s-ElSs](https://m.youtube.com/watch?v=UUx0_s-ElSs)

Arduino control flow:  
[https://m.youtube.com/watch?v=QpPGGuaGbCA](https://m.youtube.com/watch?v=QpPGGuaGbCA)

Arduino data types:  
[https://m.youtube.com/watch?v=xmZXWMEltEc](https://m.youtube.com/watch?v=xmZXWMEltEc)

Understanding Destructive LC Voltage Spikes:  
[https://www.pololu.com/docs/0J16/all](https://www.pololu.com/docs/0J16/all)  
OR  
[https://www.pololu.com/docs/pdf/0J16/destructive\_LC\_voltage\_spikes.pdf](https://www.pololu.com/docs/pdf/0J16/destructive_LC_voltage_spikes.pdf)

Why MOSFET gate resistors:  
[https://youtu.be/o0OHGWCZ7B0](https://youtu.be/o0OHGWCZ7B0)

Some things to read

LCD information:  
[https://learn.adafruit.com/character-lcds?view=all](https://learn.adafruit.com/character-lcds?view=all)  
OR  
[https://cdn-learn.adafruit.com/downloads/pdf/character-lcds.pdf?timestamp=1573085286](https://cdn-learn.adafruit.com/downloads/pdf/character-lcds.pdf?timestamp=1573085286)

Reading a schematic:  
[https://learn.sparkfun.com/tutorials/how-to-read-a-schematic](https://learn.sparkfun.com/tutorials/how-to-read-a-schematic)

Language Reference:  
[https://www.arduino.cc/en/Reference/HomePage](https://www.arduino.cc/en/Reference/HomePage)

Foundations:  
[https://www.arduino.cc/en/Tutorial/Foundations](https://www.arduino.cc/en/Tutorial/Foundations)

How and Why to avoid delay():  
[http://playground.arduino.cc/Code/AvoidDelay](http://playground.arduino.cc/Code/AvoidDelay)

Demonstration code for several things at the same time.  
[http://forum.arduino.cc/index.php?topic=223286.0](http://forum.arduino.cc/index.php?topic=223286.0#bot)

Multitasking:  
Part 1:  
[https://learn.adafruit.com/multi-tasking-the-arduino-part-1?view=all](https://learn.adafruit.com/multi-tasking-the-arduino-part-1?view=all)

Part 2:  
[https://learn.adafruit.com/multi-tasking-the-arduino-part-2?view=all](https://learn.adafruit.com/multi-tasking-the-arduino-part-2?view=all)

Part 3:  
[https://learn.adafruit.com/multi-tasking-the-arduino-part-3?view=all](https://learn.adafruit.com/multi-tasking-the-arduino-part-3?view=all)

Sparkfun Tutorials:  
[https://learn.sparkfun.com/tutorials?page=all](https://learn.sparkfun.com/tutorials?page=all)

Micro Controllers:  
[https://learn.adafruit.com/mcus-how-do-they-work?view=all](https://learn.adafruit.com/mcus-how-do-they-work?view=all)

Useful links:  
[https://forum.arduino.cc/index.php?topic=384198.0](https://forum.arduino.cc/index.php?topic=384198.0)

Arduino programming traps, tips and style guide:  
[http://www.gammon.com.au/forum/?id=12153](http://www.gammon.com.au/forum/?id=12153)

Arduino programming course:  
[https://startingelectronics.org/software/arduino/learn-to-program-course/](https://startingelectronics.org/software/arduino/learn-to-program-course/)

Jeremy Blume:  
[https://m.youtube.com/playlist?list=PLA567CE235D39FA84](https://m.youtube.com/playlist?list=PLA567CE235D39FA84)

Arduino products:  
[https://www.arduino.cc/en/Main/Products](https://www.arduino.cc/en/Main/Products)

Motors/MOSFETs  
[http://www.gammon.com.au/motors](http://www.gammon.com.au/motors)

Making a library  
[https://www.arduino.cc/en/Hacking/libraryTutorial](https://www.arduino.cc/en/Hacking/libraryTutorial)

Switches:  
[http://www.gammon.com.au/forum/?id=11955](http://www.gammon.com.au/forum/?id=11955)

[https://www.amazon.ca/Arduino-Cookbook-Recipes-Enhance-Projects/dp/1449313876/ref=sr\_1\_1?ie=UTF8&qid=1522801721&sr=8-1&keywords=arduino+cookbook](https://www.amazon.ca/Arduino-Cookbook-Recipes-Enhance-Projects/dp/1449313876/ref=sr_1_1?ie=UTF8&qid=1522801721&sr=8-1&keywords=arduino+cookbook)

 ![](https://europe1.discourse-cdn.com/arduino/original/4X/5/3/f/53f3d7a7d5e31e638c429cd75fad3b784eec0a20.jpeg)

Share tips you have come across, 700+ posts:  
[https://forum.arduino.cc/index.php?topic=445951.0](https://forum.arduino.cc/index.php?topic=445951.0)

Debug discussion:  
[https://forum.arduino.cc/index.php?topic=215334.msg1575801#msg1575801](https://forum.arduino.cc/index.php?topic=215334.msg1575801#msg1575801)

Frequently Asked Questions:  
[https://www.arduino.cc/en/main/FAQ#toc10](https://www.arduino.cc/en/main/FAQ#toc10)

SMD soldering:  
[SMD soldering](https://www.bing.com/videos/search?q=soldering+smd&go=Search&qs=n&form=QBVR&sp=-1&pq=soldering+smd&sc=8-13&sk=&cvid=CF09E79836B64475A40A5673A48DBEF1)

Number 'type's.

- boolean (8 bit) - simple logical true/false, Arduino does not use single bits for bool
- byte (8 bit) - unsigned number from 0 to 255
- char (8 bit) - signed number from -128 to 127. The compiler will attempt to interpret this data type as a character in some circumstances, which may yield unexpected results
- unsigned char (8 bit) - same as 'byte'; if this is what you're after, you should use 'byte' instead, for reasons of clarity
- word (16 bit) - unsigned number from 0 to 65535
- unsigned int (16 bit)- the same as 'word'. Use 'word' instead for clarity and brevity
- int (16 bit) - signed number from -32768 to 32767. This is most commonly what you see used for general purpose variables in Arduino example code provided with the IDE
- unsigned long (32 bit) - unsigned number from 0 to 4,294,967,295. The most common usage of this is to store the result of the millis() function, which returns the number of milliseconds the current code has been running
- long (32 bit) - signed number from -2,147,483,648 to 2,147,483,647  
float (32 bit) - signed number from -3.4028235E38 to 3.4028235E38. Floating point on the Arduino is not native; the compiler has to jump through hoops to make it work. If you can avoid it, you should. We'll touch on this later. Sparkfun.

You select the 'type' best suited for your variables.

ex:

- your variable does not change and it defines a pin on the Arduino. const byte limitSwitchPin = 34;
- since an analog variable can be 0 to 1023, a byte will not do, you can select 'int'. int temperature;
- if your variable needs to be within -64 to +64 a 'char' will do nicely. char joystick;
- if your variable is used for ASCII then you need type 'char', `char myText[] = {"Raspberry Pie Smells"};`
- if your variable enables some code then boolean can be used. boolean enableFlag = false;
- millis() returns the time in ms since rebooting, unsigned long currentTime = millis();  
etc.

Oh, and have fun too 🙂 !

---

_[View the full topic](https://forum.arduino.cc/t/debounce-button-and-delays/902601)._
