示例#1
0
文件: pullup.go 项目: gonutz/gopio
func main() {
	// Open and map memory to access gpio, check for errors
	if err := gopio.Open(); err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	// Unmap gpio memory when done
	defer gopio.Close()

	// Pull up and read value
	pin.PullUp()
	fmt.Printf("PullUp: %d\n", pin.Read())

	// Pull down and read value
	pin.PullDown()
	fmt.Printf("PullDown: %d\n", pin.Read())

}
示例#2
0
文件: blinker.go 项目: gonutz/gopio
func main() {
	// Open and map memory to access gpio, check for errors
	if err := gopio.Open(); err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	// Unmap gpio memory when done
	defer gopio.Close()

	// Set pin to output mode
	pin.Output()

	// Toggle pin 20 times
	for x := 0; x < 20; x++ {
		pin.Toggle()
		time.Sleep(time.Second / 5)
	}
}