Code Monkey home page Code Monkey logo

rpi's Introduction

WiringPi-Go

Golang wrapped version of Gordon's Arduino-like WiringPi for the Raspberry Pi

Installation

install WiringPi first

cd WiringPi\wiringPi
sudo make install

go get github.com/hugozhu/rpi

GPIO numbering

wiringPi Name GPIO.BOARD GPIO.BCM
0 GPIO 0 11 17
1 GPIO 1 12 18
2 GPIO 2 13 21
3 GPIO 3 15 22
4 GPIO 4 16 23
5 GPIO 5 18 24
6 GPIO 6 22 25
7 GPIO 7 7 4
8 SDA 3 0
9 SCL 5 1
10 CE0 24 8
11 CE1 26 7
12 MOSI 19 10
13 MOSO 21 9
14 SCLK 23 11
15 TXD 8 14
16 RXD 10 15

more to read at: http://hugozhu.myalert.info/2013/03/22/19-raspberry-pi-gpio-port-naming.html

Sample codes

lcd.go

package main

import (
    . "github.com/hugozhu/rpi"
)

func main() {
    WiringPiSetup()

    //use default pin naming
    PinMode(PIN_GPIO_4, OUTPUT)
    DigitalWrite(PIN_GPIO_4, LOW)
    Delay(400)
    DigitalWrite(PIN_GPIO_4, HIGH)

    //use raspberry pi board pin numbering, similiar to RPi.GPIO.setmode(RPi.GPIO.BOARD)
    Delay(400)
    DigitalWrite(BoardToPin(16), LOW)
    Delay(400)
    DigitalWrite(BoardToPin(16), HIGH)

    //use raspberry pi bcm gpio numbering, similiar to RPi.GPIO.setmode(RPi.GPIO.BCM)
    Delay(400)
    DigitalWrite(GpioToPin(23), LOW)
    Delay(400)
    DigitalWrite(GpioToPin(23), HIGH)
}

Run

export GOPATH=`pwd`
go install github.com/hugozhu/rpi 
go run src/lcd.go 

rpi's People

Contributors

erolg avatar hugozhu avatar tcyrus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rpi's Issues

dependency error

rpi.go:97:2: cannot find package "github.com/rogpeppe/rog-go/tree/master/exp/callback"

error running lcd.go

SIGILL: illegal instruction
PC=0x2490c
signal arrived during cgo execution

goroutine 1 [syscall, locked to thread]:
runtime.cgocall_errno(0x11b24, 0x1032dfac, 0x0)
/home/pi/go/src/runtime/cgocall.go:130 +0x12c fp=0x1032df98 sp=0x1032df80
github.com/hugozhu/rpi._Cfunc_my_pinMode(0x0, 0x1)
/home/pi/CSE237B/src/github.com/hugozhu/rpi/:63 +0x4c fp=0x1032dfa8 sp=0x1032df98
github.com/hugozhu/rpi.PinMode(0x0, 0x1)
/home/pi/CSE237B/src/github.com/hugozhu/rpi/rpi.go:255 +0x2c fp=0x1032dfb4 sp=0x1032dfa8
main.main()
/home/pi/CSE237B/src/lcd.go:11 +0x30 fp=0x1032dfc0 sp=0x1032dfb4
runtime.main()
/home/pi/go/src/runtime/proc.go:63 +0x108 fp=0x1032dfe4 sp=0x1032dfc0
runtime.goexit()
/home/pi/go/src/runtime/asm_arm.s:1322 +0x4 fp=0x1032dfe4 sp=0x1032dfe4

Any ideas? Thanks!

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.