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

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 พ.ย. 2024

ความคิดเห็น • 19

  • @gyruss3239
    @gyruss3239 3 หลายเดือนก่อน

    This is the best channel on TH-cam 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  3 หลายเดือนก่อน

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

    • @gyruss3239
      @gyruss3239 3 หลายเดือนก่อน

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

  • @pcbwayluz
    @pcbwayluz 8 หลายเดือนก่อน

    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?

  • @JasonKoukliatis
    @JasonKoukliatis 9 หลายเดือนก่อน

    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  9 หลายเดือนก่อน +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: th-cam.com/video/FIYjw0AhTkA/w-d-xo.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 9 หลายเดือนก่อน

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

  • @Volker-Dirr
    @Volker-Dirr 10 หลายเดือนก่อน

    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  10 หลายเดือนก่อน

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

  • @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?

    • @playduino
      @playduino  หลายเดือนก่อน

      Hey! Arduino MEGA 2560 has more external interrupts:
      this pins can be used: 2, 3, 18, 19, 20, 21

  • @samuelgunter
    @samuelgunter 10 หลายเดือนก่อน +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 10 หลายเดือนก่อน +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  10 หลายเดือนก่อน +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()

  • @1986ah
    @1986ah 2 หลายเดือนก่อน

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

    • @playduino
      @playduino  2 หลายเดือนก่อน

      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 2 หลายเดือนก่อน

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

  • @nirvanakh66623
    @nirvanakh66623 10 หลายเดือนก่อน

    Red finger is faster? I think its was green

    • @playduino
      @playduino  10 หลายเดือนก่อน

      Omg 😆 yes