-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change AS312 class to GenericPIR and use it for HC-SR501 sensor too
- Loading branch information
Showing
5 changed files
with
33 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# | ||
# Example using a PIR motion sensor. Tested with AS312 and HC-SR501 sensors. | ||
# | ||
# General notes: | ||
# - Both sensors have a few seconds "dead time" after "motion stop" (logical 0), where further | ||
# motion will not trigger "motion start" (logical 1). | ||
# | ||
# HC-SR501 notes: | ||
# - Needs some time to warm up and start working properly. | ||
# - Set the time potentiometer to its lowest value. | ||
# - Make sure retriggering is enabled. It might be default, but there's a jumper to solder too. | ||
# | ||
require 'bundler/setup' | ||
require 'denko' | ||
|
||
board = Denko::Board.new(Denko::Connection::Serial.new) | ||
sensor = Denko::Sensor::GenericPIR.new(board: board, pin: 8) | ||
|
||
sensor.on_motion_start { print "Motion detected! \r" } | ||
sensor.on_motion_stop { print "No motion detected...\r" } | ||
|
||
# Read initial state. | ||
sensor.read | ||
|
||
sleep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters