Skip to content

gmalette/shift_registers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

shift_registers

Golang library to use shift registers on the RaspberryPi or other gobots. Can simulate any length of register.

Usage

package main

import (
  "github.com/gmalette/shift_registers"
  "github.com/hybridgroup/gobot"
  "github.com/hybridgroup/gobot/platforms/gpio"
  "github.com/hybridgroup/gobot/platforms/raspi"
  "time"
)

func main() {
  gbot := gobot.NewGobot()

  r := raspi.NewRaspiAdaptor("raspi")
  data := gpio.NewLedDriver(r, "led", "16")
  clock := gpio.NewLedDriver(r, "led", "8")
  latch := gpio.NewLedDriver(r, "led", "12")

  reg := shift_registers.NewShiftRegister(
    8,
    data,
    clock,
    latch,
    nil,
  )

  c := true
  work := func() {
    gobot.Every(1*time.Second, func() {
      reg.Write([]bool{c, c, c, c, c, c, c, c})
      c = !c
    })
  }

  robot := gobot.NewRobot("pi",
    []gobot.Connection{r},
    []gobot.Device{data, clock, latch},
    work,
  )

  gbot.AddRobot(robot)

  gbot.Start()
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages