mirror of
https://github.com/kidoman/embd
synced 2024-12-22 12:50:19 +01:00
added water sensor sample
This commit is contained in:
parent
35cbc690a5
commit
534e903925
BIN
samples/watersensor
Executable file
BIN
samples/watersensor
Executable file
Binary file not shown.
25
samples/watersensor.go
Normal file
25
samples/watersensor.go
Normal file
@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/kid0m4n/go-rpi/sensor/watersensor"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fluidSensor := watersensor.New(7)
|
||||
|
||||
for {
|
||||
isWater, err := fluidSensor.IsWet()
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
if isWater {
|
||||
log.Printf("Bot is dry")
|
||||
} else {
|
||||
log.Printf("Bot is Wet")
|
||||
}
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
}
|
||||
}
|
@ -84,7 +84,7 @@ func (d *us020) Distance() (distance float64, err error) {
|
||||
}
|
||||
|
||||
if d.debug {
|
||||
log.Print("trigetting pulse")
|
||||
log.Print("trigerring pulse")
|
||||
}
|
||||
|
||||
// Generate a TRIGGER pulse
|
||||
|
Loading…
x
Reference in New Issue
Block a user