Giter VIP home page Giter VIP logo

gogpio's Introduction

gogpio

对GPIO简单的操作
功能:
1.设置指定的GPIO口是发射还是接收口(in/out)
2.设置发射口是高电平还是低电平(1/0)
3.释放GPIO口(Close())

示例:

		package main

	import (
		"github.com/rehtt/gogpio"
		"log"
	)

	func main() {
		//绑定针脚号(BCM)
		pin1 := gogpio.PinBind(20)
		pin2:=gogpio.PinBind(21)
		pin3:=gogpio.PinBind(22)

		//声明针脚为out输出
		out, err := pin1.SetOut()
		if err!=nil {
			log.Println(err)
		}
		out.High()								//输出高电平
		out.Low()								//输出低电平

		//声明针脚为in输入
		in,err:=pin2.SetIn()
		if err!=nil {
			log.Println(err)
		}
		log.Println(in.Read())					//读取输入的数据

		//不声明,直接读取数据。时合在其他程序使用此针脚时读取其数据
		log.Println(pin3.Read())

		//释放
		pin1.Close()
		pin2.Close()
		pin3.Close()
	}


gogpio's People

Contributors

rehtt avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.