Index

LED


Allows user to interact with LEDs through digital output and PWM (Pulse Width Modulation)

API Reference

How To Connect

Install the package with: go get github.com/hybridgroup/gobot

For Arduino:

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() {
          led.On
        }

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

        robot.Start()
}
...

How To Use

This example turns an LED on and off every 1s.

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()
}

Circuit

Compatibility