rpi

package module
v0.0.0-...-bce6190 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2016 License: MIT Imports: 4 Imported by: 15

README

go-rpigpio

GoDoc MIT License

This package provides a really simple interface for interacting with the GPIO pins on a Raspberry Pi.

Usage

The following example demonstrates writing to GPIO2:

import "github.com/nathan-osman/go-rpigpio"

p, err := rpi.OpenPin(2, rpi.OUT)
if err != nil {
    panic(err)
}
defer p.Close()

// set the pin to high (on)
p.Write(rpi.HIGH)

// set the pin to low (off)
p.Write(rpi.LOW)

Documentation

Index

Constants

View Source
const (
	IN  = iota // pin is used for input
	OUT        // pin is used for output
)
View Source
const (
	LOW  = iota // pin is low (off)
	HIGH        // pin is high (on)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Direction

type Direction int

Indicate whether the pin is used for input or output.

type Pin

type Pin struct {
	// contains filtered or unexported fields
}

An individual GPIO pin.

func OpenPin

func OpenPin(number int, direction Direction) (*Pin, error)

Prepare a pin for input or output.

func (*Pin) Close

func (p *Pin) Close() error

Close the pin.

func (*Pin) Read

func (p *Pin) Read() (Value, error)

Read the current value of the pin.

func (*Pin) Write

func (p *Pin) Write(value Value) error

Set the current value of the pin.

type Value

type Value int

Indicate the current state of the pin.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL