Exemplo n.º 1
0
func NewRangeFinder(e, t int) RangeFinder {
	var rf rangeFinder

	rf.sensor = us020.New(e, t)

	return &rf
}
Exemplo n.º 2
0
func main() {
	rangeFinder := us020.New(10, 9)

	for {
		distance, err := rangeFinder.Distance()
		if err != nil {
			log.Panic(err)
		}
		log.Printf("Distance is %v", distance)

		time.Sleep(500 * time.Millisecond)
	}
}