RPi 06 - Counter Using Interrupt

Поділитися
Вставка
  • Опубліковано 23 січ 2025

КОМЕНТАРІ • 16

  • @geirha75
    @geirha75 2 роки тому +1

    Thanks for a nice tutorial. I'm just wondering. Can your code be modified to count pulses from a anemometer? There are like 20 pules in one revolution.

    • @tsbrownie
      @tsbrownie  2 роки тому +1

      Yes, but I find you need a dedicated device just to do that or the results are not very accurate. I have a few videos from this one to one about ultrasonic measurement, and they all have accuracy problems if you ask the microcontroller to do more than count.

    • @geirha75
      @geirha75 2 роки тому +1

      @@tsbrownie One more question, tsbrownie. In your comment, the code, where # Pin 7 = 3,3V photodiode OFF.
      Maybe I don't get it, but how come the photodiode is off when detecting HIGH on pin 7? ( after interrupt on rising ).

    • @tsbrownie
      @tsbrownie  2 роки тому +1

      @@geirha75 It's been a long time so I'm not sure, but if I remember correctly., it works backward from what you expect. It's an easy experiment to try both ways to see.

  • @johnathanbaker8453
    @johnathanbaker8453 5 років тому +1

    Can this setup be used to input the "count" amount into a mysql database? If so could you demonstrate?

    • @tsbrownie
      @tsbrownie  5 років тому +3

      Don't know, never tried it. Almost sounds like someone got a homework assignment. ;)

    • @codingwithalfred
      @codingwithalfred 4 роки тому +1

      Wow... thinking outside the box... The only way i can think of achieving this will be to print the count to serial, then use some kind of application to stream/save the serial data to mysql database.

  • @jordigrau3625
    @jordigrau3625 3 роки тому +1

    Just what i was looking for. Thank you so much.

  • @jackparker596
    @jackparker596 5 років тому +2

    Nice explanation. I didn't see where you declared 'channel'.

    • @tsbrownie
      @tsbrownie  5 років тому +1

      Excellent point. The first parameter in the interrupt (the "7") is moved to the variable "channel".

  • @dukiiii
    @dukiiii 5 років тому +2

    GPIO.input(channel) > 0.5
    Why 0.5 and not == 1? Isn't GPIO on RPi digital?
    Thank you!

    • @tsbrownie
      @tsbrownie  5 років тому +1

      Because > 0.5 is more inclusive than ==1. I got caught in school on a trick my teacher played and I never forgot it.

    • @dukiiii
      @dukiiii 5 років тому +1

      Just to be clear...
      There is no way that GPIO.input(channel) result be anything else except 0 or 1 (True/False), right?
      Can't be (in any circumstances) betveen 0 and 1?

    • @tsbrownie
      @tsbrownie  5 років тому +3

      It should be true or false (0 or 1). But since you don't know the logic / code behind the test, you can not say for sure there is "no way" for it to be other. Python is famous for its approximate math. I have some videos on that also. Why risk crashing a billion dollar lander over some little oddity in the code? It happens.

    • @dukiiii
      @dukiiii 5 років тому +1

      OK, that's fine answer! Thank you!