What are external Interrupts? - (Arduino Uno Programming for Beginners)

Поделиться
HTML-код
  • Опубликовано: 2 окт 2024

Комментарии • 18

  • @pcbwayluz
    @pcbwayluz 7 месяцев назад

    Very detailed and thorough. Were wondering if any of our custom service like PCBs would be helpful in your future projects. Can anyway reach you out?

  • @spy8464BB
    @spy8464BB День назад

    Hello, Does the rule regarding the UNO and pins 2 and 3 for the Interrupt function apply to the MEGA 2560 R3 board?

  • @gyruss3239
    @gyruss3239 Месяц назад

    This is the best channel on RUclips for Arduino tutorials! You have a knack for teaching this.
    Idea for a future video(?): I'm trying to integrate a TM1637 into my project. While the project is idle, the TM1637 displays a static number. After a button command is given, a motor runs and while the motor is running I'd like the TM1637 to illuminate one segment and make the segment crawl around the display like an hourglass timer. When the motor stops, a static number would again be displayed. I've written the routine that makes the segment crawl around but I'm using delays to accomplish this and of course that delays the rest of the code.

    • @playduino
      @playduino  Месяц назад

      Thank you! This sounds like a great application for a timer library or millis() ;)

    • @gyruss3239
      @gyruss3239 Месяц назад

      @@playduino Thanks! I'll check out your millis video 🙂

  • @JasonKoukliatis
    @JasonKoukliatis 8 месяцев назад

    Great video and explanation! Two questions if I might. 1. Can you use delay function inside the ISR? 2. Can I have an internal loop inside an ISR so as to do 3 parallel things? (one on main loop and 2 parallel jobs and checks on pins 2 and 3). Finally, can I "share" variables between main loop and ISR functions (volatile maybe or something?). Thanks a lot for the great video.

    • @playduino
      @playduino  8 месяцев назад +2

      Thank you for the kind words, 1) no, they are not working. The ISR needs to be quick, so the best thing to do in an ISR is to change a variable and leave the ISR.
      2) unfortunately no. Arduino does not support multitasking. You can only execute one loop at a time.
      The best thing that comes very close to multitasking is to write non-blocking code.
      take a look at my video 15 about millis: ruclips.net/video/FIYjw0AhTkA/видео.htmlsi=ZCbUe6wDghEty-Xc
      3) yes! it works great with global volatile variables you need to add volatile otherwise you could run into some troubles. You need to define them outside of setup() and loop() usually at the very top of the sketch.

    • @JasonKoukliatis
      @JasonKoukliatis 8 месяцев назад

      @@playduino Thank you very much for your prompt reply! I will watch your video right away. Thanks again!

  • @samuelgunter
    @samuelgunter 9 месяцев назад +1

    can an interrupt interrupt another interrupt? for example, could the buttons be pressed at the precise time that the other interrupt is triggered to run after one of the lights turn on but before the interrupts are unregistered?

    • @NormanNodDunbar
      @NormanNodDunbar 9 месяцев назад +1

      During an interrupt, further interrupts are disabled. You can, if you know what you are doing, enable interrupts in an ISR but it's not recommended.
      Cheers,
      Norm. (Author: Arduino Interrupts published by Apress)

    • @playduino
      @playduino  9 месяцев назад +1

      very good question, as @NormanNodDunbar already pointed out, inside the ISR, interrupts are disabled by default.
      if you really need it, you can call the function interrupts() inside of the ISR to enable them, you can also disable them again by calling noInterrupts()

  • @Volker-Dirr
    @Volker-Dirr 9 месяцев назад

    Very nice video. Well explained and perfekt view on source and hardware. Just very minor possible improvement: At the end you didn't demonstrated on the hardware, that the other player can't win anymore, since you detached the interrupt.

    • @playduino
      @playduino  9 месяцев назад

      Thank you for the nice feedback :) I agree, however both LEDs would have turned on after my test with two fingers

  • @1986ah
    @1986ah 27 дней назад

    But using this with noisy enviroment, it becomes a problem and impossible to use

    • @playduino
      @playduino  27 дней назад

      maybe you can explain your concerns in more detail. of course everything breaks at a certain emc noise level. Adding some capacitors in parallel to the switch would help you in this type of environments.

    • @1986ah
      @1986ah 27 дней назад

      @@playduino yes, i've no choice. Using a hardware solution is more abvious in this case. Thanks for your help

  • @nirvanakh66623
    @nirvanakh66623 9 месяцев назад

    Red finger is faster? I think its was green