2014-03-02 12:36:34 +05:30
|
|
|
// +build ignore
|
|
|
|
|
2013-12-23 16:39:52 +05:30
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2014-04-05 01:43:16 +05:30
|
|
|
"flag"
|
2013-12-23 16:39:52 +05:30
|
|
|
"time"
|
|
|
|
|
2014-03-02 12:21:29 +05:30
|
|
|
"github.com/golang/glog"
|
2014-03-03 00:51:23 +05:30
|
|
|
"github.com/kidoman/embd"
|
2014-02-10 05:05:41 +05:30
|
|
|
"github.com/kidoman/embd/sensor/watersensor"
|
2014-04-06 06:50:09 +05:30
|
|
|
|
|
|
|
_ "github.com/kidoman/embd/host/all"
|
2013-12-23 16:39:52 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2014-04-05 01:43:16 +05:30
|
|
|
flag.Parse()
|
|
|
|
|
2014-03-03 00:51:23 +05:30
|
|
|
if err := embd.InitGPIO(); err != nil {
|
2014-03-02 12:21:29 +05:30
|
|
|
panic(err)
|
|
|
|
}
|
2014-03-03 00:51:23 +05:30
|
|
|
defer embd.CloseGPIO()
|
2014-03-02 12:21:29 +05:30
|
|
|
|
2014-03-03 00:51:23 +05:30
|
|
|
pin, err := embd.NewDigitalPin(7)
|
2014-03-02 12:21:29 +05:30
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
defer pin.Close()
|
|
|
|
|
|
|
|
fluidSensor := watersensor.New(pin)
|
2013-12-23 16:39:52 +05:30
|
|
|
|
|
|
|
for {
|
2014-03-02 12:21:29 +05:30
|
|
|
wet, err := fluidSensor.IsWet()
|
2013-12-23 16:39:52 +05:30
|
|
|
if err != nil {
|
2014-03-02 12:21:29 +05:30
|
|
|
panic(err)
|
2013-12-23 16:39:52 +05:30
|
|
|
}
|
2014-03-02 12:21:29 +05:30
|
|
|
if wet {
|
|
|
|
glog.Info("bot is dry")
|
2014-02-10 05:05:41 +05:30
|
|
|
} else {
|
2014-03-02 12:21:29 +05:30
|
|
|
glog.Info("bot is Wet")
|
2014-02-10 05:05:41 +05:30
|
|
|
}
|
2014-03-02 12:21:29 +05:30
|
|
|
|
2013-12-23 16:39:52 +05:30
|
|
|
time.Sleep(500 * time.Millisecond)
|
|
|
|
}
|
|
|
|
}
|