All Projects → brian-armstrong → Gpio

brian-armstrong / Gpio

Licence: bsd-3-clause
Go library to do GPIO on systems with /sys/class/gpio (sysfs)

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Gpio

Periph
Go·Hardware·Lean
Stars: ✭ 1,700 (+1316.67%)
Mutual labels:  raspberry-pi, hardware, gpio
Pigpio
Fast GPIO, PWM, servo control, state change notification and interrupt handling with Node.js on the Raspberry Pi
Stars: ✭ 747 (+522.5%)
Mutual labels:  raspberry-pi, gpio
Brachiograph
BrachioGraph is an ultra-cheap (total cost of materials: €14) plotter that can be built with minimal skills.
Stars: ✭ 498 (+315%)
Mutual labels:  raspberry-pi, hardware
Cimonitor
Displays CI statuses on a dashboard and triggers fun modules representing the status!
Stars: ✭ 34 (-71.67%)
Mutual labels:  raspberry-pi, gpio
Cylon
JavaScript framework for robotics, drones, and the Internet of Things (IoT)
Stars: ✭ 3,862 (+3118.33%)
Mutual labels:  raspberry-pi, gpio
W1thermsensor
A Python package and CLI tool to work with w1 temperature sensors like DS1822, DS18S20 & DS18B20 on the Raspberry Pi, Beagle Bone and other devices.
Stars: ✭ 446 (+271.67%)
Mutual labels:  hardware, gpio
Iobroker.deconz
Connects to deConz software developed by dresden-elektronik. This software aims to be a universal ZigBee Gateway solution, using hardware from dresden-elektronik the ConBee USB stick and RaspBee a modul for the Raspberry Pi.
Stars: ✭ 33 (-72.5%)
Mutual labels:  raspberry-pi, hardware
gopio
Raspberry pi GPIO controller package(CGO)
Stars: ✭ 14 (-88.33%)
Mutual labels:  gpio, hardware
Swiftygpio
A Swift library for hardware projects on Linux/ARM boards with support for GPIOs/SPI/I2C/PWM/UART/1Wire.
Stars: ✭ 1,188 (+890%)
Mutual labels:  raspberry-pi, gpio
Mraa
Linux Library for low speed IO Communication in C with bindings for C++, Python, Node.js & Java. Supports generic io platforms, as well as Intel Edison, Intel Joule, Raspberry Pi and many more.
Stars: ✭ 1,220 (+916.67%)
Mutual labels:  raspberry-pi, gpio
Gopi
Raspberry Pi Go Language Interface
Stars: ✭ 82 (-31.67%)
Mutual labels:  raspberry-pi, gpio
Blynk Library
Blynk library for embedded hardware. Works with Arduino, ESP8266, Raspberry Pi, Intel Edison/Galileo, LinkIt ONE, Particle Core/Photon, Energia, ARM mbed, etc.
Stars: ✭ 3,305 (+2654.17%)
Mutual labels:  raspberry-pi, hardware
Octoprint Enclosure
OctoPrint Enclosure Plugin
Stars: ✭ 267 (+122.5%)
Mutual labels:  raspberry-pi, gpio
Rppal
A Rust library that provides access to the Raspberry Pi's GPIO, I2C, PWM, SPI and UART peripherals.
Stars: ✭ 463 (+285.83%)
Mutual labels:  raspberry-pi, gpio
gobot
Golang framework for robotics, drones, and the Internet of Things (IoT)
Stars: ✭ 7,869 (+6457.5%)
Mutual labels:  gpio, hardware
Upboard ros
ROS nodes for upboard usage
Stars: ✭ 22 (-81.67%)
Mutual labels:  hardware, gpio
Gpiozero
A simple interface to GPIO devices with Raspberry Pi
Stars: ✭ 1,302 (+985%)
Mutual labels:  raspberry-pi, gpio
Pikvm
Open and cheap DIY IP-KVM based on Raspberry Pi
Stars: ✭ 3,950 (+3191.67%)
Mutual labels:  raspberry-pi, hardware
Mqtt Io
Expose GPIO modules (Raspberry Pi, Beaglebone, PCF8754, PiFace2 etc.) and digital sensors (LM75 etc.) to an MQTT server for remote control and monitoring.
Stars: ✭ 234 (+95%)
Mutual labels:  raspberry-pi, gpio
Onoff
GPIO access and interrupt detection with Node.js
Stars: ✭ 1,050 (+775%)
Mutual labels:  raspberry-pi, gpio

GPIO

This is a Go library for general purpose pins on Linux devices which support /sys/class/gpio. This implementation conforms to the spec. An advantage of using /sys/class/gpio is that we can receive interrupt-like notifications from the kernel when an input changes, rather than polling an input periodically. See the notes on Watcher for more info.

I have only tested it so far on Raspberry Pi but it should also work on similar systems like the Beaglebone. If you test this library on another system please tell me so that I can confirm it -- I'll give you credit here for the confirmation.

Note that the GPIO numbers we want here as the CPU/kernel knows them, not as they may be marked on any external hardware headers.

Input

Call pin := gpio.NewInput(number) to create a new input with the given pin numbering. You can then access the value of this pin with pin.Read(), which returns 0 when the pin's value is logic low and 1 when high.

If you are only concerned with when the pin's value changes, consider using gpio.Watcher instead.

Output

Call pin := gpio.NewOutput(number, high), where high is a bool that describes the initial value of the pin -- set to false if you'd like the pin to initialize low, and true if you'd like it to initialize high.

Once you have a pin, you can change its value with pin.Low() and pin.High().

Watcher

The Watcher is a type which listens on the GPIO pins you specify and then notifies you when the values of those pins change. It uses a select() call so that it does not need to actively poll, which saves CPU time and gives you better latencies from your inputs.

Here is an example of how to use the Watcher.

watcher := gpio.NewWatcher()
watcher.AddPin(22)
watcher.AddPin(27)
defer watcher.Close()

go func() {
    for {
        pin, value := watcher.Watch()
        fmt.Printf("read %d from gpio %d\n", value, pin)
    }
}()

This example would print once each time the value read on either pin 22 or 27 changes. It also prints each pin once when starting.

Alternately, users may receive from watcher.Notification directly rather than calling watcher.Watch(). This channel yields WatcherNotification objects with Pin and Value fields.

License

3-clause BSD

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].