import "gobot.io/x/gobot/platforms/firmata"
Package firmata provides the Gobot adaptor for microcontrollers that support the Firmata protocol.
Installing:
go get -d -u gobot.io/x/gobot/... && go get gobot.io/x/gobot/platforms/firmata
Example:
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() }
For further information refer to firmata readme: https://github.com/hybridgroup/gobot/blob/master/platforms/firmata/README.md
ble_firmata_adaptor.go doc.go firmata_adaptor.go firmata_i2c.go tcp_firmata_adaptor.go
const ( // ReceiveID is the BLE characteristic ID for receiving serial data ReceiveID = "6e400003b5a3f393e0a9e50e24dcca9e" // TransmitID is the BLE characteristic ID for transmitting serial data TransmitID = "6e400002b5a3f393e0a9e50e24dcca9e" )
NewFirmataI2cConnection creates an I2C connection to an I2C device at the specified address
type Adaptor struct { Board firmataBoard PortOpener func(port string) (io.ReadWriteCloser, error) gobot.Eventer // contains filtered or unexported fields }
Adaptor is the Gobot Adaptor for Firmata based boards
NewAdaptor returns a new Firmata Adaptor which optionally accepts:
string: port the Adaptor uses to connect to a serial port with a baude rate of 57600 io.ReadWriteCloser: connection the Adaptor uses to communication with the hardware
If an io.ReadWriteCloser is not supplied, the Adaptor will open a connection to a serial port with a baude rate of 57600. If an io.ReadWriteCloser is supplied, then the Adaptor will use the provided io.ReadWriteCloser and use the string port as a label to be displayed in the log and api.
AnalogRead retrieves value from analog pin. Returns -1 if the response from the board has timed out
Connect starts a connection to the board.
DigitalRead retrieves digital value from specified pin. Returns -1 if the response from the board has timed out
DigitalWrite writes a value to the pin. Acceptable values are 1 or 0.
Disconnect closes the io connection to the Board
Finalize terminates the firmata connection
GetConnection returns an i2c connection to a device on a specified bus. Only supports bus number 0
GetDefaultBus returns the default i2c bus for this platform
Name returns the Firmata Adaptors name
Port returns the Firmata Adaptors port
PwmWrite writes the 0-254 value to the specified pin
ServoConfig sets the pulse width in microseconds for a pin attached to a servo
ServoWrite writes the 0-180 degree angle to the specified pin.
SetName sets the Firmata Adaptors name
BLEAdaptor represents a Bluetooth LE based connection to a microcontroller running FirmataBLE
func NewBLEAdaptor(args ...interface{}) *BLEAdaptor
NewBLEAdaptor opens and uses a BLE connection to a microcontroller running FirmataBLE
type FirmataAdaptor interface { Connect() (err error) Finalize() (err error) Name() string SetName(n string) WriteSysex(data []byte) error gobot.Eventer }
TCPAdaptor represents a TCP based connection to a microcontroller running WiFiFirmata
func NewTCPAdaptor(args ...interface{}) *TCPAdaptor
NewTCPAdaptor opens and uses a TCP connection to a microcontroller running WiFiFirmata
Path | Synopsis |
---|---|
client | Package client provies a client for interacting with microcontrollers using the Firmata protocol https://github.com/firmata/protocol. |
Package firmata imports 10 packages (graph) and is imported by 18 packages. Updated 2020-12-01. Refresh now. Tools for package owners.