buspirate

package module
v0.0.0-...-3d1586c Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2014 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package buspirate interfaces with the binary mode of the BusPirate. http://dangerousprototypes.com/docs/Bus_Pirate

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BusPirate

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

BusPirate represents a connection to a remote BusPirate device.

func Open

func Open(dev string) (*BusPirate, error)

Open opens a connection to a BusPirate module and places it into binary mode.

func (*BusPirate) PowerOff

func (bp *BusPirate) PowerOff()

PowerOff turns off the 5v and 3v3 regulators.

func (*BusPirate) PowerOn

func (bp *BusPirate) PowerOn()

PowerOn turns on the 5v and 3v3 regulators.

func (*BusPirate) SetPWM

func (bp *BusPirate) SetPWM(duty float64)

SetPWM enables PWM output on the AUX pin with the specified duty cycle. duty is clamped between [0, 1].

Example

Pulse a LED connected to the AUX pin.

bp, err := buspirate.Open("/dev/ttyACM0")
if err != nil {
	panic(err)
}
duty := 0.1
delta := 0.1
for {
	bp.SetPWM(duty)
	time.Sleep(50 * time.Millisecond)
	duty += delta
	if duty > 1.0 {
		duty = 1.0
		delta = -delta
	}
	if duty < 0 {
		duty = 0.0
		delta = -delta
	}
}
Output:

Jump to

Keyboard shortcuts

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