mirror of
https://github.com/kidoman/embd
synced 2025-07-03 03:47:33 +02:00
added water sensor sample
This commit is contained in:
parent
35cbc690a5
commit
534e903925
3 changed files with 26 additions and 1 deletions
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)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue