GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Gobot
  • Docs
  • Platforms
  • Resources
  • News
  • Blog
  • Github
  • Getting Started
  • Classic Gobot
  • Master Gobot
  • Metal Gobot
  • Adding Hardware Support
  • CLI
  • Snapcraft

This view

  • Original page
  • New address

GeezerVison is showing gobot.io — Gobot Example - chip_button

Index

package main

import (
        "fmt"

        "gobot.io/x/gobot"
        "gobot.io/x/gobot/drivers/gpio"
        "gobot.io/x/gobot/platforms/chip"
)

func main() {
        chipAdaptor := chip.NewAdaptor()
        button := gpio.NewButtonDriver(chipAdaptor, "XIO-P0")

        work := func() {
                button.On(gpio.ButtonPush, func(data interface{}) {
                        fmt.Println("button pressed")
                })

                button.On(gpio.ButtonRelease, func(data interface{}) {
                        fmt.Println("button released")
                })
        }

        robot := gobot.NewRobot("buttonBot",
                []gobot.Connection{chipAdaptor},
                []gobot.Device{button},
                work,
        )

        robot.Start()
}
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.