Skip to content

Commit

Permalink
Call #stop on ultrasonic echo pin before use to avoid lgpio alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
vickash committed Aug 25, 2024
1 parent 5e03dd0 commit 61032f1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/denko/sensor/hcsr04.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def initialize_pins(options={})
def after_initialize(options={})
super(options)

# Avoid generating extraneous alerts when used with Denko::PiBoard.
echo.stop

# Receive values from echo pin.
echo.add_callback { |data| self.update(data) }
end
Expand Down

0 comments on commit 61032f1

Please sign in to comment.