Level Up Your Arduino Code: External Interrupts

preview_player
Показать описание

We examine external interrupts on this episode of Adventures in Science as we continue our journey learning about the inner workings of Arduino. External interrupts are anything that’s outside (but connected to) the microcontroller and can interrupt the main execution thread to perform some action. We look at the attachInterrupt() Arduino function and then break it apart to set up an interrupt by manually writing to registers.
Рекомендации по теме
Комментарии
Автор

Wow you just taught me more about low level programming in one video than I've learned in 3 years of school

jacoblakies
Автор

Wow. Great video. The most clear and concise presenter I have ever heard. Every word is clear and although he talks quickly I can slow down it to make it easier. I'm a 71yr old newbie in Arduino and this guy is sharp.Kudos

dennismcdonald
Автор

Wow, I just finished the Register video and was feeling good that I got it finally. So I jumped into this video and all was going great until 1 second before 12:00. For the next 2:30 seconds I felt I was listening to a new language. I rewound the section countless times and read the sections over and over in the datasheet, and I finally the parts started to make sense and I finally understood your code.
I appreciate your video, if I had to rely on the datasheet alone I would give up my project completely. You have given me new hope that I can figure out how to make my code work.


I swear there was a point when I was reading the datasheet that I almost had to hit a AA meeting or the bar. It felt like if I had a couple drinks in me then I could better understand where the guy was coming from when he wrote that datasheet.


There is one part I don't understand and perhaps someone can clarify it for me.
When I was reading about the "External Interrupts" it mentions that they can be triggered by either INT1 or INT0, and it also mentions that any of the other pins (PCINT 23-0) can also trigger an external interrupt. I see that the EICRA bit configures how and when the trigger is detected (low-level, rising-edge, or falling-edge) for the INT0/1 registers, but I don't see a similar register for the PCINT pins. Am I missing something here?

danblankenship
Автор

Man I have to tell you're the best of the best teacher, cause you give me all I need as basics to enter this arduino world, which was dark to me as no experience in coding/programming. So clear and explicit, keep going teaching us brother, God gives you heath, and wisdom to continue your service for this arduino community. 😎👏👏👏

lucsonnelson
Автор

You are a great instructor. Always so well done.

cyrix_
Автор

I started understanding better what code is since I follow you. Wish I had discovered your videos before today, I would have had done way better with my robotic mower project. I was mad and frustrated the fact that I couldn't find any helpful examples. Some people built good one but selfish about to share with others, I got it "money ideas for later". Yeah, I had bad headaches trying to think about a way around it to bring my ideas to life. I'm going to keep up with you to see where it'll lead me. So far awesome to follow you and probably my favorite and interesting human to receive notifications from. Thanks again.

lucsonnelson
Автор

loving these tutorial style videos Sparkfun! Keep 'em going!

tigeruby
Автор

Spent an hour last night trying to figure out why changing a variable value wasn't working and IT NEEDED TO BE VOLATILE. Thank you!

devincress
Автор

Awesome! A masterclass in 2 vids! Now it's time to try it making some tests as exercise.
Thanks, Professor!

randomrandom
Автор

Thanks for the fantastic explanation! I used some of these methods in my own projects and they have worked well.

I would like to add from my own project experience that it may help to add a cap to ground at the INT0 pin in order to prevent unwanted/false falling edge detections. This may be an issue if you have a cheap button that has a ripple to it, or perhaps there are just ripples in your system in general.

gingsSon
Автор

also make on uart, spi, i2c, protocol and ADC

rohit-lohar
Автор

Thank you so much for helping with this. This was an absolute life-saver! <3

nexus
Автор

I really enjoy how these videos are made to reduce down to the arduino code to basic instructions. It feels like these tutorials are for real programmers (like myself) and I'm learning all these new and neat little tricks with & | ~ and ^

johnson
Автор

I so enjoy and learn so much fro m your video learning series. I cannot thank you enough. I can't wait until the next one. Thanks again Dave.

davewreski
Автор

Yeah, this & the few other videos that led me here are outstanding. I have many questions, but I want to focus on one. Around 9 min in there’s a statement “led_state = !led_state” for toggling. Defined as “LOW” (pre-setup) w/ uint8_t. If uint8_t has 0-255 as possibilities, how does a ‘!’ simply toggle between only the two states “HIGH” and “LOW”? Does “HIGH” set the 8 bits of uint8_t to and the ‘!’ is saying to toggle all 8 of led_state’s bits to “opposite” being for a value equivalent to “LOW”?

johngrund
Автор

This smart short video is loaded with tons of useful info, keep up the awesome videos ;)

afnansayed
Автор

Even simpler, in the ISR, toggle the led_pin by writing a 1 to its bit in PIND:

PIND |= (1 << led_pin);

It's in the data sheet and is quicker than the XOR.

NormanNodDunbar
Автор

indeed, you video sparked fun in learning electronics. thank you so much!

lowiehojas
Автор

Extremely awesome!! I've no words to appreciate your awesome work.

rishabhbhatnagar
Автор

Really excellent job of presenting this material. THANKS!!!!

waltoler