gobot.io/x/gobot/v2@v2.1.0/examples/firmata_bmp180.go (about) 1 //go:build example 2 // +build example 3 4 // 5 // Do not build by default. 6 7 package main 8 9 import ( 10 "fmt" 11 "os" 12 "time" 13 14 "gobot.io/x/gobot/v2" 15 "gobot.io/x/gobot/v2/drivers/i2c" 16 "gobot.io/x/gobot/v2/platforms/firmata" 17 ) 18 19 func main() { 20 firmataAdaptor := firmata.NewAdaptor(os.Args[1]) 21 bmp180 := i2c.NewBMP180Driver(firmataAdaptor) 22 23 work := func() { 24 gobot.Every(1*time.Second, func() { 25 t, _ := bmp180.Temperature() 26 fmt.Println("Temperature", t) 27 28 p, _ := bmp180.Pressure() 29 fmt.Println("Pressure", p) 30 }) 31 } 32 33 robot := gobot.NewRobot("bmp180bot", 34 []gobot.Connection{firmataAdaptor}, 35 []gobot.Device{bmp180}, 36 work, 37 ) 38 39 robot.Start() 40 }