mcp3008

package
v0.0.0-...-c75e8ed Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2018 License: Apache-2.0 Imports: 2 Imported by: 0

README

Read value from ADT MCP3008

Example

package main

import (
        "time"
        "fmt"
        mcp "github.com/jdevelop/golang-rpi-extras/mcp3008"
        )

func main() {

	const channel = 0

	// /dev/spidev0.0
	mcp, err := mcp.NewMCP3008(0, 0, mcp.Mode0, 500000)
	
	if err != nil {
		panic(err.Error())
	}

	for {
		fmt.Println(mcp.Measure(channel))
		time.Sleep(time.Second)
	}

}

Documentation

Index

Constants

View Source
const (
	Mode0 = Mode(0)
	Mode1 = Mode(1)
	Mode2 = Mode(2)
	Mode3 = Mode(3)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MCP3008

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

func NewMCP3008

func NewMCP3008(bus int, busChannel int, mode Mode, maxSpeed int64) (mcp MCP3008, resErr error)

func (MCP3008) Measure

func (r MCP3008) Measure(channel int) (result int, err error)

type MeasureAnalog

type MeasureAnalog interface {
	Measure(channel int) (result int, err error)
}

type Mode

type Mode int

Jump to

Keyboard shortcuts

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