Index

Classic Gobot

The simplest way to create robots, and drones, and Internet connected things, is to use "Classic Gobot".

Remember the "Hello, World of Things" aka "Blink" code example from the "Getting Started" page? This is a good example of "Classic Gobot" in action:

package main

import (
        "time"

        "gobot.io/x/gobot"
        "gobot.io/x/gobot/drivers/gpio"
        "gobot.io/x/gobot/platforms/firmata"
)

func main() {
        firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
        led := gpio.NewLedDriver(firmataAdaptor, "13")

        work := func() {
                gobot.Every(1*time.Second, func() {
                        led.Toggle()
                })
        }

        robot := gobot.NewRobot("bot",
                []gobot.Connection{firmataAdaptor},
                []gobot.Device{led},
                work,
        )

        robot.Start()
}

How to use Classic Gobot

The Robot is the main abstraction you use when working with Classic Gobot. You can create a new Robot using the gobot.NewRobot() function.

Pass in the slice of one or more Connection structs, a slice of one or more Device structs, and a function with the Work that the Robot is expected to do.

Once your Robot is created, you then call the Start() function.