Documentation ¶
Overview ¶
Package digispark provides the Gobot adaptor for the Digispark ATTiny-based USB development board.
Installing:
This package requires installing `libusb`. Then you can install the package with:
go get github.com/hybridgroup/gobot/platforms/digispark
Example:
package main import ( "time" "github.com/hybridgroup/gobot" "github.com/hybridgroup/gobot/platforms/digispark" "github.com/hybridgroup/gobot/platforms/gpio" ) func main() { gbot := gobot.NewGobot() digisparkAdaptor := digispark.NewDigisparkAdaptor("Digispark") led := gpio.NewLedDriver(digisparkAdaptor, "led", "0") work := func() { gobot.Every(1*time.Second, func() { led.Toggle() }) } robot := gobot.NewRobot("blinkBot", []gobot.Connection{digisparkAdaptor}, []gobot.Device{led}, work, ) gbot.AddRobot(robot) gbot.Start() }
For further information refer to digispark README: https://github.com/hybridgroup/gobot/blob/master/platforms/digispark/README.md
Index ¶
- Variables
- type DigisparkAdaptor
- func (d *DigisparkAdaptor) Connect() (errs []error)
- func (d *DigisparkAdaptor) DigitalWrite(pin string, level byte) (err error)
- func (d *DigisparkAdaptor) Finalize() (errs []error)
- func (d *DigisparkAdaptor) Name() string
- func (d *DigisparkAdaptor) PwmWrite(pin string, value byte) (err error)
- func (d *DigisparkAdaptor) ServoWrite(pin string, angle uint8) (err error)
Constants ¶
This section is empty.
Variables ¶
var ErrConnection = errors.New("connection error")
ErrConnection is the error resulting of a connection error with the digispark
Functions ¶
This section is empty.
Types ¶
type DigisparkAdaptor ¶
type DigisparkAdaptor struct {
// contains filtered or unexported fields
}
DigisparkAdaptor is the Gobot Adaptor for the Digispark
func NewDigisparkAdaptor ¶
func NewDigisparkAdaptor(name string) *DigisparkAdaptor
NewDigisparkAdaptor returns a new DigisparkAdaptor with specified name
func (*DigisparkAdaptor) Connect ¶
func (d *DigisparkAdaptor) Connect() (errs []error)
Connect starts a connection to the digispark
func (*DigisparkAdaptor) DigitalWrite ¶
func (d *DigisparkAdaptor) DigitalWrite(pin string, level byte) (err error)
DigitalWrite writes a value to the pin. Acceptable values are 1 or 0.
func (*DigisparkAdaptor) Finalize ¶
func (d *DigisparkAdaptor) Finalize() (errs []error)
Finalize implements the Adaptor interface
func (*DigisparkAdaptor) Name ¶
func (d *DigisparkAdaptor) Name() string
Name returns the DigisparkAdaptors name
func (*DigisparkAdaptor) PwmWrite ¶
func (d *DigisparkAdaptor) PwmWrite(pin string, value byte) (err error)
PwmWrite writes the 0-254 value to the specified pin
func (*DigisparkAdaptor) ServoWrite ¶
func (d *DigisparkAdaptor) ServoWrite(pin string, angle uint8) (err error)
ServoWrite writes the 0-180 degree val to the specified pin.