Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/racerxdl/go-mcp23017
GoLang MCP23017 driver that uses Linux I2C calls
https://github.com/racerxdl/go-mcp23017
arduino electronics golang gpio i2c mcp23017 raspberry-pi
Last synced: 2 months ago
JSON representation
GoLang MCP23017 driver that uses Linux I2C calls
- Host: GitHub
- URL: https://github.com/racerxdl/go-mcp23017
- Owner: racerxdl
- License: mit
- Created: 2019-07-09T20:00:27.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-19T18:13:23.000Z (almost 5 years ago)
- Last Synced: 2024-06-20T22:44:36.391Z (7 months ago)
- Topics: arduino, electronics, golang, gpio, i2c, mcp23017, raspberry-pi
- Language: Go
- Size: 19.5 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-mcp23017
GoLang MCP23017 driver that uses Linux I2C calls
Based on Adafruit Arduino Implementation: https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library/
# Example Usage
This code snippet turns on each I/O sequentially and then turns off.
```go
package mainimport (
"github.com/quan-to/slog"
"github.com/racerxdl/go-mcp23017"
"time"
)var log = slog.Scope("TEST")
func main() {
d, err := mcp23017.Open(1, 0)
if err != nil {
log.Error(err)
}defer d.Close()
for i := 0; i < 16; i++ {
err := d.PinMode(uint8(i), mcp23017.OUTPUT)
if err != nil {
log.Error(err)
}
}for {
log.Info("Turning On")
for i := 0; i < 16; i++ {
err = d.DigitalWrite(uint8(i), mcp23017.HIGH)
if err != nil {
log.Error(err)
}
time.Sleep(time.Millisecond * 100)
}
time.Sleep(time.Second)
log.Info("Turning Off")
for i := 0; i < 16; i++ {
err = d.DigitalWrite(uint8(i), mcp23017.LOW)
if err != nil {
log.Error(err)
}
time.Sleep(time.Millisecond * 100)
}
}
}```