Ep. 58 - Arduino Advanced Input & Button Control, Debouncing, Counters & Multitasking

preview_player
Показать описание
Contribute to the channel:

Blog Post & More Info:

In this tutorial, we are taking a step back and diving deep into advanced input & button control with Arduino. This is a highly requested topic on my videos as well as the Arduino website. I'm covering how to work with pull-ups, how to properly capture toggles inputs, how to debounce buttons and much more.

Get in touch:

Software:

Relevant Links:
N/A

Relevant Search Terms:
EEEnthusiast, Vlad Romanov, Volodymyr Romanov, Arduino, Arduino, Arduino button debounce, arduino button, arduino button counter, Arduino tutorial, arduino IO, arduino inputs and outputs, arduino button tutorial, arduino programming, arduino multitasking, arduino uno, arduino pull up resistor, arduino led,
Рекомендации по теме
Комментарии
Автор

Very good video. Useful for those, who don't want to use libraries like ONE BUTTON
...for example, if you don't have physical buttons but instead soft-buttons created by an MPR121 capacitive sensor.
Greetings from Germany.

BerndSchmitt-Martinique
Автор

THANK YOU. Most helpful video/code I've come across. All I wanted to do is have 4 buttons turn 4 different LEDs on/off... who knew this would be so complicated lol

eatonasher
Автор

The use of Enum (like in C) and Array[ ] will simplify this design.

fifaham
Автор

Thanks for the video! Learning how to structure the program in an ordered and "modular" way was extremely helpful for my project!

mattamath
Автор

I would like to see detailed commenting in your code. That would help to understand it better. Thanks for video.

karlis
Автор

Very useful ! All the best for you!! :)

danutdarauta
Автор

thank you very much bro, really helpful, GOD BLESS YOU.

rosewald
Автор

For the switch case part, could you use an array instead?
because all of those case results do the same thing, except for having changes of the number value for the LED brightness....

mb
Автор

Great thank u for these explanations ! clear and useful :)

simonwinczlav
Автор

Hi your lesson is very great i learn a lot but my arduino ide is giving me a lot of problem it when i write const int or int or define button it keep saying button = 2; was not
initialize

martinspence
Автор

HI...I made a code kinda same as yours for debouncing and in there I created different functions to be called with onebutton as per the number of pushes. Then I want functions to interrupt in btw as per the number of Pushes.
For reference :
singleTap() = // executes the following steps etc
doubleTap() =// perform some other steps etc.
Now, here while singleTap function is being executed, i push double Taps and singleTap function should stop and doubleTap be function must be executed and vice-versa. In short the functions must be independent of each other.
I did attach pushbutton as Interrupt so as to read continuously from it to avoid polling reading through the Pushbutton but the program did not perform as expected.
How would you make this program?

deathmetallicand
Автор

Thanks again. I think you did really well with these two examples on video's 58 and 59. Perhaps you could go a little further into this subject. What I'm working on is fairly fundamental and would work well with these uploads. Perhaps an explanation of my challenges will inspire you to do something along these lines at some point. I'm not asking you to solve my problems here or write my code. I'm just trying to share something I have found challenging as a simple hobbyist and viewer.
I was trying to add a 1602 lcd to his code but had a lot of problems getting it to work. His example is a rotary encoder and menu but the menu is only implemented on the serial monitor. Also, I don't understand how or why he has used a button press timer to 'change modes' or settings. It's like a solution without a problem as far as I understand it. I was really interested in trying to understand the lack of pullup resistors and code delay/debounce he used.

I really liked your example with a relatable, real world application in video 59. I am looking to build a similar type of design.
I have an old flatscreen TV I tore apart and I am turning into a light box type of overhead bench light. I have a bunch of LED strips I used to replace the CCFL's. I have 3 different types of LEDs, Neutral, Cold, and Warm White. I want to have a small 1602 display and rotary encoder that can control the different White LED colors. I also want to use a few PWM channels to control the main light's output. Ideally I should probably use PWM on all channels but I don't know if that's even possible at this point. Anyways...my point is that I haven't found anyone that explained how to use this combination, a rotary encoder, lcd, and control an output. The output part is fairly easy. I'm using a simple circuit I picked up from Lewis Loflin (another YT CC's website) here (no affiliation):
I have a bunch of cheap AliEx TIP127's (PNP Darlington[100v/5A]) transistors already so I figured I'd use them. I'm mentioning it because I haven't seen any content that covers these 3 elements together, a rotary encoder, lcd, and versatile switching application. It seems so fundamental, I'm surprised I'm finding it challenging to find an example.
My project is probably going to use a temperature sensor and fan along with an attempt at adding a few WS2811 RGB's too but that's not my point here.
Another aspect I would really like to understand better is how to make this kind of code modular. Let's say you designed a product with a 4 button interface and the customer decided they want a rotary encoder or touchscreen, how would you write code that could be changed without a complete rewrite?
Anyways, those are just some ideas and real world challenges I'm facing as a code noob. Perhaps you'll find some use for such a perspective ;)
Thanks for the upload.
-Jake

UpcycleElectronics
join shbcf.ru