Don't Use DigitalRead | Arduino Interrupt Programming Guide

  Рет қаралды 18,345

RoboCircuits

RoboCircuits

Күн бұрын

Пікірлер: 69
@nassimkoubeissi5814
@nassimkoubeissi5814 2 жыл бұрын
this is one of the basics in all programming languages in microchip assembly hardware interrupt can be used for many things including reading buttons as long as there are no delay loops in interrupt routine it is very effective and fast way . I use interrupt to read switches set variable I=100 in the main declaration for variables and in in hardware interrupt routine also set I=100 as soon as it finishes the interrupt and returns back to main program then I do a software interrupt using call subroutine and put a counter example I=I-1 and disable hardware interrupt in this loop then checks I if =0 then enable hardware interrupt and set I =100 if not exit subroutine I do not use any delay in the software subroutine and rely on instructions delay when the program counter is executing every instruction in main program (depends on the clock frequency used by your MCU ) the benefits are no impact on main program and my MCU ignores any button until 100 main program loops are done . another note I=100 is for example demo not a fix value it depends on the main program how long are the instructions and normal delay loops in it . use delay loops only when necessarily needed . I hope that helps .
@RoboCircuits
@RoboCircuits 2 жыл бұрын
I completely agree with you… the method you suggested is even better
@guatagel2454
@guatagel2454 2 жыл бұрын
Interrupts may require some state machine if the algorithm gets bigger and bigger. Saying "don't use digitalread" is misleading, because interrupts do not solve every problem. You know this, but you prefer the clickbait.
@RoboCircuits
@RoboCircuits 2 жыл бұрын
But its a point worth learning for a lot of people
@guatagel2454
@guatagel2454 2 жыл бұрын
@@RoboCircuits you should say that, then. "digitalRead is not always the best idea", or "alternatives to digitalRead", or "when digitalRead is not the fastest solution".
@chrisisaacson647
@chrisisaacson647 Ай бұрын
I came here to say the same thing.. great instructions on how to use interrupts and why, but not always the only or best solution. Software engineering is knowing all your options an picking what is best for your situation.
@shrikantnikam2426
@shrikantnikam2426 2 жыл бұрын
Standard practice use millis insted delay then no need of external interrrupt bcz less pins to use.
@ClaudioParraGonzalez
@ClaudioParraGonzalez 2 жыл бұрын
Could you please elaborate?
@shrikantnikam2426
@shrikantnikam2426 2 жыл бұрын
@@ClaudioParraGonzalez suppose you use delay in program of 5ms and controller executing that delay and that time any button pressed then controller will not accept that button bcz it have only one core and we cant do multitasking solution is use external hardware interrupt but pins are isr pins limited on arduino then solution for this only one that is dont use delay in program use millis, find out how millis replace dalay, checkout my channel Mr tech inventor
@RoboCircuits
@RoboCircuits 2 жыл бұрын
Yes its true… but if code is big then we can miss the press of button if not implemented properly
@AF_Pereira
@AF_Pereira 6 ай бұрын
Sure, but still you will mess with code scalability, hence interrupts is still better than polling and mils... That's only good to know how long the key is pressed for special purposes in the code for example...
@phoenixflames6019
@phoenixflames6019 Жыл бұрын
I am really happy to see a video on some slightly advanced interrupt handling, but as far as I know, using `delay()` in the ISR definition is not a good practice. In fact, the watchdog timer would ideally run out way before something like `delay(150000)` executes. I have experienced this while using a few `Serial.println()` calls in my ISR definition. Printing data a few times onto the serial monitor takes long enough to exhaust the watchdog timer, causing the microcontroller to reset. 😂 Am I right? Or am I missing something?
@flyingrobots4937
@flyingrobots4937 2 жыл бұрын
Awesome video… best explanation of interrupts i have seen
@RoboCircuits
@RoboCircuits 2 жыл бұрын
Thank you
@creativewonder1152
@creativewonder1152 2 жыл бұрын
Really useful video 👌😁
@RoboCircuits
@RoboCircuits 2 жыл бұрын
Thank you
@borwankarsunil
@borwankarsunil Жыл бұрын
Sir, I am designing a working model of lift. In that I am using push buttons. For that, I incorporated all three solutions provided by you. But the code is giving error- Compilation error. Expected initializer before 'extern'. What does it mean? Should I 'include' some function from library?
@venkateshpriya1984
@venkateshpriya1984 5 ай бұрын
Brow I2C communication interrupt tutorial in ESP32
@RoboCircuits
@RoboCircuits 4 ай бұрын
Its similar
@vandita7196
@vandita7196 2 жыл бұрын
Great efforts👍🏻🔥
@RoboCircuits
@RoboCircuits 2 жыл бұрын
Thank you for supporting
@sanjaybatra6593
@sanjaybatra6593 Жыл бұрын
1. Nice explanation of interrupts. I have a question , you have explained about how to use interrupt for a BUTTON ( single button). but in real system , there are 3-5 buttons .....like MENU Button , UP button, DOWN button , ENTER button . How to deal with this situation ? 2. suppose I want to use a keypad of size 4x4 or 4x5, how to deal with this situation. can a interrupt will be generated for any key pressed ?
@RoboCircuits
@RoboCircuits Жыл бұрын
During keypads, you need to check 2 pins at the same time.. there you can use interrupt. But you need to be a little creative. I never tried but i will try and let you know.
@RoboCircuits
@RoboCircuits Жыл бұрын
Using multiple interrupts is fine. Just make sure isr should be as small as possible
@sanjaybatra6593
@sanjaybatra6593 Жыл бұрын
@@RoboCircuits I wish to know your viewpoint, how to implement and use interrupt when there are multiple BUTTONS.
@RoboCircuits
@RoboCircuits Жыл бұрын
In case of keypad.. i never tried. But i have tried 4 pushbuttons and 4 interrupts and it works
@sanjaybatra6593
@sanjaybatra6593 Жыл бұрын
@@RoboCircuits From your statement I got any idea to use interrupt for keypad. 2 pins can be given to any logic gate and output of logic gate will be single.
@TheDiverJim
@TheDiverJim Жыл бұрын
You need a cap to denounce. Depending on what edge you care about, you can just use a cap, or a cap and resistor
@axramar1992
@axramar1992 11 ай бұрын
Nice explanation 🎉keep it up Any RTOS tutorials? Semaphore Mutex Threads?
@JmChauhan-hp4dz
@JmChauhan-hp4dz Жыл бұрын
Bro when i give high at pin 10 high and read pin 10 and pin 11input and both get high(1) value . So why this occur you can say.
@shrikantnikam2426
@shrikantnikam2426 2 жыл бұрын
Bro where are you now job?
@RoboCircuits
@RoboCircuits 2 жыл бұрын
A little busy with other things… but will get back soon
@ChrisWilliams-pu8pj
@ChrisWilliams-pu8pj 11 ай бұрын
Nicely done. Thank you!
@0124akash
@0124akash 11 ай бұрын
Properly explained, why and how. Thankyou sir. But can you make vdo in Hindi language for 100% understanding.
@AF_Pereira
@AF_Pereira 6 ай бұрын
Applying a 10nF capacitor would solve most of the issues. I was actually expecting way much more. Reading one button is easy... Reading several is another thing... You will have interrupt overlap and might break something... I would do a totally different approach...
@RoboCircuits
@RoboCircuits 4 ай бұрын
I will try using a 10nf capacitor… it was a simple tutorial you can use multiple buttons as well
@mamadoubapassioninformatique
@mamadoubapassioninformatique 2 жыл бұрын
Good to know. Thanks for sharing.
@RoboCircuits
@RoboCircuits 2 жыл бұрын
You are welcome… thanks for appreciation
@mohammadjunaid3200
@mohammadjunaid3200 Жыл бұрын
Do you know how to use a note acceptor machine if you know can you teach me I will also pay you money for this
@RoboCircuits
@RoboCircuits Жыл бұрын
Note acceptor?
@emileballard4417
@emileballard4417 2 жыл бұрын
i dont like useing interrupts for this i use it for more important stuff. i use if(buttonstate != prevbuttonstate){ if(buttonstate == HIGH){ //do stuff..... } } prevbuttonstate = buttonstate; and the longer de code gets the bounce issue manly disapears and if i doesnt, i use millis(). but DONT USE delay its bad in most cases.
@RoboCircuits
@RoboCircuits 2 жыл бұрын
True… i will implement it Thanks for sharing
@guatagel2454
@guatagel2454 2 жыл бұрын
You hit a very important nerve here: interrupts are difficult to learn, and if you use 2 or more sources of interrupts you will need some state machine to keep track of what the program is doing. Some problems requires interrupts and interrupts are the only solution. But you have to think your program very well.
@creativeelectronics6266
@creativeelectronics6266 2 жыл бұрын
very nice
@RoboCircuits
@RoboCircuits 2 жыл бұрын
Thank you
@ClaudioParraGonzalez
@ClaudioParraGonzalez 2 жыл бұрын
thanks, good video
@RoboCircuits
@RoboCircuits 2 жыл бұрын
Welcome 😄😄😄😄
@sudheerkumar5966
@sudheerkumar5966 2 жыл бұрын
Very good
@RoboCircuits
@RoboCircuits 2 жыл бұрын
Thank you
@АндрійПрокопович-х6х
@АндрійПрокопович-х6х 2 жыл бұрын
Thanks
@RoboCircuits
@RoboCircuits 2 жыл бұрын
Welcome 😀 thanks for appreciation
@nishants.robocircuits
@nishants.robocircuits 2 жыл бұрын
👍👍
@RoboCircuits
@RoboCircuits 2 жыл бұрын
Thank you
@kennyberg338
@kennyberg338 Жыл бұрын
Why annoying music
@x-6790
@x-6790 2 жыл бұрын
nice
@RoboCircuits
@RoboCircuits 2 жыл бұрын
Thank you
@x-6790
@x-6790 2 жыл бұрын
@@RoboCircuits so brilliant you are after a month replied 🤣🤣
@ensarija
@ensarija Жыл бұрын
I will teach you... Indian guys 😁
@RoboCircuits
@RoboCircuits Жыл бұрын
🤣
@shaygoldin
@shaygoldin 10 ай бұрын
Nice video. You should realy use a good microphone, lose the music, it's not mixed well, and maybe talk a bit slower, so people who are not nThanks anyway.
@serutipkrobart4070
@serutipkrobart4070 2 жыл бұрын
hello, this is cienna from Beijing DWIN Technology company, I visited your youtube platform,I believe there is a strong possibility for us to work with you, we are LCD manufacturer for 19 years,we have hundreds kind of LCD display,and our products could connect with Arduino, ESP32,STM32 etc, so I believe there is a strong possibility for us to work with you.
@RoboCircuits
@RoboCircuits 2 жыл бұрын
I replied to your mail
@p.k.electronics4981
@p.k.electronics4981 Жыл бұрын
😂
@serutipkrobart4070
@serutipkrobart4070 2 жыл бұрын
and i send you email today, pls check it and thank you😀😀
@RoboCircuits
@RoboCircuits 2 жыл бұрын
Your email address
Pin Change Interruptions ISR | PCINT | Arduino101
14:19
Electronoobs
Рет қаралды 59 М.
JISOO - ‘꽃(FLOWER)’ M/V
3:05
BLACKPINK
Рет қаралды 137 МЛН
$1 vs $500,000 Plane Ticket!
12:20
MrBeast
Рет қаралды 122 МЛН
КОНЦЕРТЫ:  2 сезон | 1 выпуск | Камызяки
46:36
ТНТ Смотри еще!
Рет қаралды 3,7 МЛН
Жездуха 41-серия
36:26
Million Show
Рет қаралды 5 МЛН
How to Use Arduino Interrupts The Easy Way
33:28
Rachel De Barros
Рет қаралды 95 М.
#328 ESP32 Secrets: Interrupts, and Deep-Sleep under the Hood
18:57
Andreas Spiess
Рет қаралды 180 М.
Level Up Your Arduino Code: Registers
21:09
SparkFun Electronics
Рет қаралды 187 М.
PlatformIO: All you need to know in 10 Minutes!
10:56
J's e-shack
Рет қаралды 344 М.
LESSON 28: Tutorial for Programming Software Interrupts on Arduino
25:14
Level Up Your Arduino Code: External Interrupts
18:55
SparkFun Electronics
Рет қаралды 175 М.
How to make a 16x16x16 LED CUBE at home with Arduino platform
20:09
Malt Whiskey
Рет қаралды 4,4 МЛН
Timer Interrupt ISR + Examples | Arduino101 | Set Registers & Modes
16:13
JISOO - ‘꽃(FLOWER)’ M/V
3:05
BLACKPINK
Рет қаралды 137 МЛН