2014-03-02 08:06:34 +01:00
|
|
|
// +build ignore
|
|
|
|
|
2013-12-23 12:09:52 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2014-03-02 07:51:29 +01:00
|
|
|
"github.com/golang/glog"
|
|
|
|
"github.com/kidoman/embd/gpio"
|
2014-02-10 00:35:41 +01:00
|
|
|
"github.com/kidoman/embd/sensor/watersensor"
|
2013-12-23 12:09:52 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2014-03-02 07:51:29 +01:00
|
|
|
if err := gpio.Open(); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
defer gpio.Close()
|
|
|
|
|
|
|
|
pin, err := gpio.NewDigitalPin(7)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
defer pin.Close()
|
|
|
|
|
|
|
|
fluidSensor := watersensor.New(pin)
|
2013-12-23 12:09:52 +01:00
|
|
|
|
|
|
|
for {
|
2014-03-02 07:51:29 +01:00
|
|
|
wet, err := fluidSensor.IsWet()
|
2013-12-23 12:09:52 +01:00
|
|
|
if err != nil {
|
2014-03-02 07:51:29 +01:00
|
|
|
panic(err)
|
2013-12-23 12:09:52 +01:00
|
|
|
}
|
2014-03-02 07:51:29 +01:00
|
|
|
if wet {
|
|
|
|
glog.Info("bot is dry")
|
2014-02-10 00:35:41 +01:00
|
|
|
} else {
|
2014-03-02 07:51:29 +01:00
|
|
|
glog.Info("bot is Wet")
|
2014-02-10 00:35:41 +01:00
|
|
|
}
|
2014-03-02 07:51:29 +01:00
|
|
|
|
2013-12-23 12:09:52 +01:00
|
|
|
time.Sleep(500 * time.Millisecond)
|
|
|
|
}
|
|
|
|
}
|