Documentation ¶
Overview ¶
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
Index ¶
- type Adaptor
- func (f *Adaptor) AnalogRead(pin string) (val int, err error)
- func (f *Adaptor) Connect() (err error)
- func (f *Adaptor) DigitalRead(pin string) (val int, err error)
- func (f *Adaptor) DigitalWrite(pin string, level byte) (err error)
- func (f *Adaptor) Disconnect() (err error)
- func (f *Adaptor) Finalize() (err error)
- func (f *Adaptor) I2cRead(address int, size int) (data []byte, err error)
- func (f *Adaptor) I2cStart(address int) (err error)
- func (f *Adaptor) I2cWrite(address int, data []byte) (err error)
- func (f *Adaptor) Name() string
- func (f *Adaptor) Port() string
- func (f *Adaptor) PwmWrite(pin string, level byte) (err error)
- func (f *Adaptor) ServoConfig(pin string, min, max int) error
- func (f *Adaptor) ServoWrite(pin string, angle byte) (err error)
- func (f *Adaptor) SetName(n string)
- type TCPAdaptor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adaptor ¶
Adaptor is the Gobot Adaptor for Firmata based boards
func NewAdaptor ¶
func NewAdaptor(args ...interface{}) *Adaptor
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.
func (*Adaptor) AnalogRead ¶
AnalogRead retrieves value from analog pin. Returns -1 if the response from the board has timed out
func (*Adaptor) DigitalRead ¶
DigitalRead retrieves digital value from specified pin. Returns -1 if the response from the board has timed out
func (*Adaptor) DigitalWrite ¶
DigitalWrite writes a value to the pin. Acceptable values are 1 or 0.
func (*Adaptor) Disconnect ¶
Disconnect closes the io connection to the board
func (*Adaptor) I2cRead ¶
I2cRead returns size bytes from the i2c device Returns an empty array if the response from the board has timed out
func (*Adaptor) ServoConfig ¶
ServoConfig sets the pulse width in microseconds for a pin attached to a servo
func (*Adaptor) ServoWrite ¶
ServoWrite writes the 0-180 degree angle to the specified pin.
type TCPAdaptor ¶
type TCPAdaptor struct {
*Adaptor
}
TCPAdaptor represents a TCP based connection to a microcontroller running WiFiFirmata
func NewTCPAdaptor ¶
func NewTCPAdaptor(args ...interface{}) *TCPAdaptor
NewTCPAdaptor opens and uses a TCP connection to a microcontroller running WiFiFirmata
Directories ¶
Path | Synopsis |
---|---|
Package client provies a client for interacting with microcontrollers using the Firmata protocol https://github.com/firmata/protocol.
|
Package client provies a client for interacting with microcontrollers using the Firmata protocol https://github.com/firmata/protocol. |