Documentation ¶
Overview ¶
Package ep0099 controls a EP-0099 Raspberry Pi HAT with 4 relays via I2C.
Datasheet https://wiki.52pi.com/index.php/DockerPi_4_Channel_Relay_SKU:_EP-0099
Example ¶
// Initializes host to manage bus and devices if _, err := host.Init(); err != nil { log.Fatal(err) } // Opens default bus bus, err := i2creg.Open("") if err != nil { log.Fatal(err) } defer bus.Close() // Initializes device using current I2C bus and device address. // Address should be provided as configured on the board's DIP switches. dev, err := ep0099.New(bus, 0x10) if err != nil { log.Fatal(err) } defer dev.Halt() // Run device demo for _, channel := range dev.AvailableChannels() { state, _ := dev.State(channel) log.Printf("[channel %#x] Initial state: %s", channel, state) dev.On(channel) state, _ = dev.State(channel) log.Printf("[channel %#x] State after .On: %s", channel, state) dev.Off(channel) state, _ = dev.State(channel) log.Printf("[channel %#x] State after .Off: %s", channel, state) time.Sleep(2 * time.Second) }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dev ¶
type Dev struct {
// contains filtered or unexported fields
}
func (*Dev) AvailableChannels ¶
Click to show internal directories.
Click to hide internal directories.