TinyGo and Raspberry Pi Pico: GPIO and Interrupts

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 ต.ค. 2024
  • Take a dive into how we connect peripherals like LEDs and push buttons to the GPIO pins of the Pico. Then, see how easy it is to set up an Interrupt Service Routine (ISR) that performs an action when the push button is pressed or released.
    Web site: pragmatik.tech/
    Tutorial: pragmatik.tech...
    GitHub Repo: github.com/pra...

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

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

    Fantastic series! Thanks

  • @nodidog
    @nodidog ปีที่แล้ว

    Just wanted to say thanks, for putting this series out. I really appreciate it!

  • @tonygilkerson
    @tonygilkerson 2 ปีที่แล้ว +1

    This is great, I am learning how to code pico with TinoGo and there are many python examples but actual TinyGo examples are hard to find so please keep them coming. I do have a question. Is the execution of the interrupt function concurrent or parallel? For example if you were to put a sleep in your function that checks the button status would the other light pause for awhile?

    • @pragmatiktech
      @pragmatiktech  2 ปีที่แล้ว +1

      Yes it would. Although time.Sleep seems to be disabled in an interrupt service routine. I'm working on a video to illustrate this - based on this question and the one you asked on my other video. Stay tuned.

    • @pragmatiktech
      @pragmatiktech  2 ปีที่แล้ว +2

      Tony: Here you go: th-cam.com/video/7_ZSARxaR4k/w-d-xo.html

  • @jyoun79
    @jyoun79 2 ปีที่แล้ว

    Very cool!

  • @tonygilkerson
    @tonygilkerson 2 ปีที่แล้ว

    I finally got around to trying this out. I have a single push button and I SetInterrupt for when it is pressed. When pressed I print "hi". This works but sometimes it prints "hi" real quick several times if I don't push the button quickly. I think I heard someone call this pin-bouncing? Can you suggest a technique I can us to avoid this?

    • @tonygilkerson
      @tonygilkerson 2 ปีที่แล้ว

      I did some searching and found that I can fix in software or hardware, I am better at programming so I will try to fix in software. Looks like I can read the pin value in a loop and introduce a small delay when pressed to debounce. Looks like that can work but seems to make the use of SetInterrupt not needed. I like the SetInterrupt approach so any advice is appreciated

    • @pragmatiktech
      @pragmatiktech  2 ปีที่แล้ว

      @@tonygilkerson You'll need to debounce your switches. Unfortunately, I couldn't figure out an easy way to debounce in software on the Pico using TinyGo since we need to keep the ISR execution time really small. A simple hardware debouncer might do the trick.

    • @pragmatiktech
      @pragmatiktech  2 ปีที่แล้ว

      Take a look at github.com/tinygo-org/tinygo/pull/2233/files for a possible example.

    • @tonygilkerson
      @tonygilkerson 2 ปีที่แล้ว

      @@pragmatiktech I just took a look at that example, I like it... I will try that next. You are a great resource, I appreciate your help. I will report back to let you know if it works,

    • @pragmatiktech
      @pragmatiktech  2 ปีที่แล้ว +1

      @@tonygilkerson More than happy to help and to have people like you with whom I can share this learning journey.