stianeikeland / go-rpio Goto Github PK
View Code? Open in Web Editor NEW:electric_plug: Raspberry Pi GPIO library for go-lang
License: MIT License
:electric_plug: Raspberry Pi GPIO library for go-lang
License: MIT License
if err := rpio.Open(); err != nil {
fmt.Println(err)
b.GPIOEnabled = false
return
} else {
b.GPIOEnabled = true
}
ButtonPinPullUp := rpio.Pin(ButtonPin)
ButtonPinPullUp.PullUp()
res2 := ButtonPinPullUp.Read()
fmt.Printf("Read after pull-up: %v\n", res2)
user@host:~ $ ~/executable
Read after pull-up: 0
Am I incorrect in my understanding that an input pin connected to a pull-up resistor should read high after being set to pull-up?
I am getting this error.
Hi!
In the standard gpio python library you have an option to active_high=False
, do you have that in this library for go?
Python code:
pin = gpiozero.OutputDevice(2, active_high=False)
Because now the go code looks bonkers, when I want to send a HIGH signal for two seconds on GPIO 2 I have to write the opposite:
func openDoor() {
doorRemote.Low()
time.Sleep(time.Second * 2)
doorRemote.High()
}
Excerpt from the docs:
active_high (bool) – If True (the default), the on() method will set the GPIO to HIGH. If False, the on() method will set the GPIO to LOW (the off() method always does the opposite).
Using the mod feature of newly released go1.11 and importing go-rpio as a library causes a downgrade to v3.0.0
.
In go.mod
file, the version is listed as github.com/stianeikeland/go-rpio v3.0.0+incompatible
, where:
v3.0.0
is the larges version tagged following the SIV, since 4.0.0
and 4.1.0
are missing v
so they are ignored.+incompatible
prevent the import path from adding the major version.Adding the tags v4.0.0
and v4.1.0
should fix the immediate problem.
more information about +incompatible flag form another Go project.
Anybody ever dockerize an app using this library on a raspberry pi? Is it as simple as just making a volume for /dev/mem
?
@stianeikeland If you can share any other files / devices the library needs access to that'd be awesome
I'm working with an RGB led strip and i'd like to be able to control the brightness via the gpio, but with this lib i only get High or Low, no way to do it in between.
Just wondering if it's possible?
Thanks.
I found a small issue with the library. For some reason when rpio is close and EdgeDetect is still enable it will hard lock the rpi. i tested it on both a pi3 and pi4. if i call pin.Detect(rpio.NoEdge) before close nothing locks up and everything is fine. I don't have any logs unfortunately dmsg and the kernel log give no insight.
go version: go1.17 linux/arm64
kernel version (uname-a): Linux XXXX 5.13.0-1013-raspi #15-Ubuntu SMP PREEMPT Fri Jan 7 23:16:57 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux
go-rpio version: 4.5.1
I try go-rpio with an Orange PI Lite board to toggle the BCM pin 6 but it does not work. I note that the board works fine with WiringOP and .net iot. Does go-rpio actually support Orange PI boards?
Hi,
I think it would be very useful if you can add a function which measure the frequency a GPIO pin change status. This will allow to interface with a multitude of sensors.
Some examples of implementation in C are here: http://abyz.me.uk/rpi/pigpio/examples.html#C_code
Arduino core library has a conceptually similar functio called pulseIn:
https://www.arduino.cc/reference/en/language/functions/advanced-io/pulsein/
I tried to use a loop with pin.EdgeDetected() and a microsecond sleep but my RPI freezes all the time.
Thanks
I tried to build and run the pullup example https://github.com/stianeikeland/go-rpio/blob/master/examples/pullup/pullup.go. But it does not build, see error message:
pi@raspberrypi ~/g/e/pullup> go build
# github.com/stianeikeland/go-rpio/v4/examples/pullup
./pullup.go:26:48: pin.ReadPull undefined (type rpio.Pin has no field or method ReadPull)
./pullup.go:30:50: pin.ReadPull undefined (type rpio.Pin has no field or method ReadPull)
note: module requires Go 1.13~
After I removed the ReadPull()
call, I got the following output:
pi@raspberrypi ~/g/e/pullup> ./pullup
PullUp: 0, 0
PullDown: 0, 0
That means PullUp does not work.
Go can restrict compilation with build tags. It would be nice if the code refused to build/run tests on non-Raspberry, or at least non-ARM platforms.
// +build arm
for any code that touches hardware would be a good safety net.
Hi,
Have you considered adding input interrupts? You can get them from the files exposed by sysfs in /sys/class/gpio. I've made a library which does this at https://github.com/brian-armstrong/gpio
sysfs can also expose i2c and spi if you uncomment the modules in /boot/config.txt and then reboot. This might be an easy way for you to add i2c and spi functionality as well.
I get the following output when I get this package. I'm running Windows 10 with go version go1.5.1 windows/amd64
> go get github.com/stianeikeland/go-rpio
# github.com/stianeikeland/go-rpio
..\..\..\github.com\stianeikeland\go-rpio\rpio.go:290: undefined: syscall.Mmap
..\..\..\github.com\stianeikeland\go-rpio\rpio.go:294: undefined: syscall.PROT_READ
..\..\..\github.com\stianeikeland\go-rpio\rpio.go:294: undefined: syscall.PROT_WRITE
..\..\..\github.com\stianeikeland\go-rpio\rpio.go:295: undefined: syscall.MAP_SHARED
..\..\..\github.com\stianeikeland\go-rpio\rpio.go:315: undefined: syscall.Munmap
I assume this has something to do with: https://golang.org/s/go1.4-syscall
I'm having a very strange issue here, hopefully someone can shed some light on the subject.
go 1.14, raspberry pi 4 B+
using the blinker.go example:
./blinker works just fine
sudo ./blinker makes nothing happen.
Why is this? Normally that would be fine, except that I'm trying to use rpio along with a dht11 library that requires root access to run. I find it perplexing that running rpio with heightened privileges causes it to not work.
I'm running this code (just experimenting for now) and after some time (about 1 minute) device is going to be stuck.
(I did the same actions with another languages: python, nodejs, but nothing, everything works stable and great, but when running this go application - I have a stuck and need just manually disconnect device from power supply and enable again).
I have Raspberry Pi 3 Model B.
Hardware : BCM2835
Revision : a22082
Kernel: 4.19.58-v7+
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 10 (buster)
Release: 10
Codename: buster
package main
import (
"fmt"
"github.com/stianeikeland/go-rpio"
"log"
"time"
)
func main() {
err := rpio.Open()
if err != nil {
log.Fatal(err)
}
ch := make(chan struct{})
pin := rpio.Pin(10)
pin.Input()
pin.PullUp()
pin.Detect(rpio.FallEdge)
lastTime := time.Now().UnixNano() / 1000000
go func() {
for {
if pin.EdgeDetected() {
now := time.Now().UnixNano() / 1000000
diff := now - lastTime
lastTime = now
fmt.Println("Heyhey!", diff)
}
time.Sleep(time.Millisecond * 10)
}
}()
fmt.Println("init")
<-ch
}
The following code from rpio.Open implies that /dev/mem and /dev/gpiomem are equivalent, the latter only ignores certain writes:
// Open fd for rw mem access; try dev/mem first (need root)
file, err = os.OpenFile("/dev/mem", os.O_RDWR|os.O_SYNC, 0)
if os.IsPermission(err) { // try gpiomem otherwise (some extra functions like clock and pwm setting wont work)
file, err = os.OpenFile("/dev/gpiomem", os.O_RDWR|os.O_SYNC, 0)
}
However judging from http://www.macs.hw.ac.uk/~hwloidl/hackspace/linux/drivers/char/broadcom/bcm2835-gpiomem.c, /dev/gpiomem only maps the GPIO page.
The following program, running as non-root only, crashes a Raspberry 3 Model B+ latest at the first attempt to set the duty cycle. Crashing means “not reachable via IP anymore” in my case, presumably because random GPIO memory was overwritten.
package main
import (
"fmt"
rpio "github.com/stianeikeland/go-rpio"
"time"
)
func main() {
rpio.Open()
defer rpio.Close()
p := rpio.Pin(12)
p.Mode(rpio.Pwm)
p.Freq(4688 * 0xFFFF)
for i := 0; i <= int(^uint16(0)); i++ {
fmt.Println("setting", i)
p.DutyCycle(uint32(i), 0xffff)
time.Sleep(10 * time.Millisecond)
}
}
Hi,
when importing the package for v4 like
import "github.com/stianeikeland/go-rpio/v4"
I get this error:
main.go:32:2: cannot find package "github.com/stianeikeland/go-rpio/v4" in any of:
/usr/local/go/src/github.com/stianeikeland/go-rpio/v4 (from $GOROOT)
go get github.com/stianeikeland/go-rpio/v4
cannot find package "github.com/stianeikeland/go-rpio/v4" in any of:
/usr/local/go/src/github.com/stianeikeland/go-rpio/v4 (from $GOROOT)
returns the same error. What am I missing here?
go version: go version go1.12.9 linux/arm
export GO111MODULE=on
go code:
import (
"log"
"time"
rpio "github.com/stianeikeland/go-rpio"
)
func main() {
err := rpio.Open()
if err != nil {
log.Fatalf("open rpio error %v", err)
}
defer rpio.Close()
red := rpio.Pin(13)
red.Output()
red.Low()
for {
red.High()
time.Sleep(time.Second)
red.Low()
time.Sleep(time.Second)
}
}
we i run my binary, the red light didn't respond.
pinout
,--------------------------------.
| oooooooooooooooooooo J8 +======
| 1ooooooooooooooooooo PoE | Net
| Wi oo +======
| Fi Pi Model 4B V1.1 oo |
| ,----. +====
| |D| |SoC | |USB3
| |S| | | +====
| |I| `----' |
| |C| +====
| |S| |USB2
| pwr |HD| |HD| |I||A| +====
`-| |---|MI|---|MI|----|V|-------'
Revision : b03111
SoC : BCM2711
RAM : 2048Mb
Storage : MicroSD
USB ports : 4 (excluding power)
Ethernet ports : 1
Wi-fi : True
Bluetooth : True
Camera ports (CSI) : 1
Display ports (DSI): 1
J8:
3V3 (1) (2) 5V
GPIO2 (3) (4) 5V
GPIO3 (5) (6) GND
GPIO4 (7) (8) GPIO14
GND (9) (10) GPIO15
GPIO17 (11) (12) GPIO18
GPIO27 (13) (14) GND
GPIO22 (15) (16) GPIO23
3V3 (17) (18) GPIO24
GPIO10 (19) (20) GND
GPIO9 (21) (22) GPIO25
GPIO11 (23) (24) GPIO8
GND (25) (26) GPIO7
GPIO0 (27) (28) GPIO1
GPIO5 (29) (30) GND
GPIO6 (31) (32) GPIO12
GPIO13 (33) (34) GND
GPIO19 (35) (36) GPIO16
GPIO26 (37) (38) GPIO20
GND (39) (40) GPIO21
For further information, please refer to https://pinout.xyz/
lscpu:
Architecture: armv7l
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 1
Core(s) per socket: 4
Socket(s): 1
Vendor ID: ARM
Model: 3
Model name: Cortex-A72
Stepping: r0p3
CPU max MHz: 1500.0000
CPU min MHz: 600.0000
BogoMIPS: 108.00
Flags: half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
and when i use python to test , it works.
#!/usr/bin/env python
import RPi.GPIO as GPIO
import time
RED = 13
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(RED, GPIO.OUT)
def Close():
GPIO.output(RED,False)
try:
while(1):
GPIO.output(RED,True)
time.sleep(1)
GPIO.output(RED,False)
time.sleep(1)
except KeyboardInterrupt:
Close()
pass
Hi,
Now I know how to use this package for pin based communication. But I want to know, how can I use serial ports (like GPRS/GSM Module) to send data from Arduino?
Thanks in advance.
Hi, I'd like to contribute again and implement functionality inspired by this bcm2835 lib example.
(In my eyes this has higher priority than software pwm duscussed in #20)
The use case is, when you want to detect short input signal, eg. fast button press (or something much much shorter), and you don't want to waste much CPU (prevent rapid pooling), but you don't mind waiting a bit to actually process the action.
Let's say the button accuation time when pressed may be as short as 10ms. In current stage, only way to reliably detect it is to sample input every 5ms, like in following example.
pin.Input()
for {
if pin.Read() == rpio.High {
println("button pressed")
}
time.Sleep(5*time.Millisecond) // wait time determines shortes detectable signal length
}
This is not much CPU effecient for long running instances.
I propose to use rise/fall edge event detection (without interruption handling like in github.com/brian-armstrong/gpio, but it would still be an improvement).
Two new pin method would be implemented. (Better naming ideas are welcomed).
func(pin) Detect(edge)
- for enabling/disabling detection of rising and/or falling edge event
GPREN
and GPFEN
registers - this functionality scans pins using clock and detect 011
and/or 100
patterns.edge
argument would be one of: NoEdge
, RiseEdge
, FallEdge
, AnyEdge
.func(pin) EdgeDetected() bool
- for checking if event has occured since last call
GPEDS
registerpin.Input()
pin.Detect(rpio.RiseEdge)
for {
if pin.EdgeDetected() {
prinln("button pressed")
}
time.Sleep(500*time.Millisecond)
// wait time only affect user experience; signal length may be as short as two CLK ticks
}
It would (partially) solve issues #18.
In the future this functionaluty might be extended over intteruption handling using blocking channel, which would avoid the neccessity to use any sleeps.
I will create pull request soon, if there are no objections.
I know this has been mentioned in several other issues but I am putting it here for a specific issue.
I'm running on a RPI 4 Model B. Running output on Pin 18 and setting the pin to High works. Setting the same Pin 18 to PWM and setting it to a 100% duty cycle does not work.
I'm running the program as root
.
There has been suggestions made that the PWM functionality was fixed for the RPI 4. This does not appear to be the case.
pwm
how to use pwm on pin 16
yahboom robot 4WD
motor pins
pwm 13 and 16 pins
https://github.com/YahboomTechnology/RaspberryPi-4WD-Car/blob/master/4.Code/python/CarRun.py
How do you install this library on the PI???????
Converted a driver for TLC95711 pwm board which uses SPI. I got it working fully with one weird issue when I have to rpio.Open() within the same function when I am writing to SPI.
With that being said, I found an issue when looping though colors and sending it through SPI, I am getting a "memory issue" according to the panic that gets thrown. I figure it's being caused when writing to SPI while a previous write hasn't finish being sent just yet. I have set up sleeps but you really can only delay so long before effects don't look right.
Would it be possible to add Locking capabilities similar to Arduino?
rising edge
and falling edge
detect for example.
I couldn't get the blinker.go example to work when I did
go run blinker.go
But when I build the file it works fine.
./blinker
Is there a way to just run the file to speed up the prototyping process?
I'm currently trying to write a golang equivalent of this Raspberry Pi LoRa hot module, which uses wiringPi pniouts.
I've tried the wiringPi pin out numbers in this golang library using go-rpio
and I'm unable to get it to work properly, and it fails with a unrecognized traceiver
error.
It should be noted that running the provided dragino examples works, so it can definitely work from this library, it's just a matter of figuring out the pin differences
Model: Raspberry Pi 3B+
No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 9.11 (stretch)
Release: 9.11
Codename: stretch
Linux rpi3 4.19.66-v7+ #1253 SMP Thu Aug 15 11:49:46 BST 2019 armv7l GNU/Linux
I am porting over the python for the waveshare 128x128 1.44in GPIO LCD display (ST7735S
),
The pins that control the buttons are by default, value 1 when no input is provided, and are dropped to value 0
The moment i use a SPI function from this library, pins 21 and 20 (key 1 and key2 respectively) are set to 0
and their state cannot be altered until either the pi Reboots, or i run the original python code, which has a gpio.cleanup
function that fixes this issue on runtime.
https://pastebin.com/L1kJXVax < main.go
https://pastebin.com/3mBfE0JD < lcd.go
Perhaps it's just me but whenever I try to use PWM the BCM pin 2 changes from ALT0 to ALT2 and suddenly it's no longer possible to use ADC chips to for example read the value of a Rotary Potentiometer and then controlling a DC motor using PWM. Doesn't seem to matter if I use PWM on BCM pin 12 or BCM 13.
Using Raspberry PI 4.
I don't see any explicit support mentioned, but I thought I'd leave this here.
Line 245 in f6236e5
I try to use python with gpio in other pins (not only in above pins).
Why limit pins in the code?
Thanks.
Not every platform supports /dev/gpio or allows /dev/mem. Support the GPIO sysfs interface if it is available on the machine. See https://www.kernel.org/doc/Documentation/gpio/sysfs.txt for details.
Hi,
I noticed some oddities with the PWM frequency when using this library, so I double-checked with a scope.. and indeed it's off.
e.g. when using pin.Freq(64000)
I'd expect a frequency of 64khz. However, I get 1.8khz on my scope.
This seems to be because of a wrong assumption about the oscillator frequency. In rpio.go, it says
const sourceFreq = 19200000 // oscilator frequency`
However, this is not correct for the PI4. According to
https://raspberrypi.stackexchange.com/questions/100622/is-default-pwm-frequency-19-2mhz-in-raspberry-3#:~:text=1%20Answer&text=The%20crystal%20oscillator%20is%2019.2,has%20a%2054%20MHz%20oscillator
the PI4 has a frequency of 54Mhz. And indeed, changing the code to
const sourceFreq = 54000000 // oscilator frequency
fixes it somewhat. However, it is still wrong by a factor of 100 - I now get a 640Hz PWM instead of a 64k PWM.
Changing it to
const sourceFreq = 540000 // oscilator frequency
now finally gives a correct result (but I guess the method is wrong - I assume the real bug is somewhere further down, but didn't check further).
Hey everyone,
first, thank you very much for creating this library. Right now, I try to build an autonomous drone and I would love use go-lang (I am a beginner in electronics and go-lang) for learning. Similar libraries written in in nodejs and python usually just use the c-library. They offer a mehod called setPulseWidth that uses set_servo_pulsewidth in C. Are there any plans to implement it in go-rpio?
Right now, I don't feel like I can help. But maybe this issue is also a good way to clearify things. In theory, I read that pulse width, duty cycle and frequency are related. Actually, it should be possible to use casual PWM in combination with duty cycle and frequency or am I wrong?
I just tried it, set the frequency to 50 and set a duty cycle like 50 % without success. Maybe you have an idea where to start or even better, how I can use the existing implementation to mimic the (servo-)pulseWidth implementation of other libraries.
Thanks in advance
(Keep up the good work!)
Using Detect
and running a very basic program on the Raspberry Pi 3, will result in the whole Raspberry Pi locking up (and needing a forced restart).
This only happens on a pin with very many rises/falls, currently I am using this for a RF receiver, so there are quite a lot of rises/falls.
The code I am using is this ...
package main
import (
"fmt"
"time"
rpio "github.com/stianeikeland/go-rpio"
)
// This program is just going to be
// a POC of the sender working.
// This should and WILL be cleaned up
// I do not care, I will not fucking
// write the report without having
// the time to do this properly
// Raspberry Pi 3 GPIO
// https://i.imgur.com/PPFf2ul.png
const rx_pin_nr = 2
var preamble = [8]int{1, 0, 1, 0, 1, 0, 1, 0}
var sfd = [8]int{1, 0, 1, 0, 1, 0, 1, 1}
var rx_pin rpio.Pin
func main() {
// initialize go-rpio
err := rpio.Open()
if err != nil {
fmt.Println(err)
}
// set our pin as a output
rx_pin = rpio.Pin(rx_pin_nr)
rx_pin.Input()
rx_pin.Detect(rpio.RiseEdge)
for {
// sendData(test)
fmt.Println("Running stuff")
time.Sleep(100 * time.Millisecond)
}
}
func check_sync() {
}
Not even doing anything with it. I don't know what the solution would be, but I think that we could get the interrupt etc. if we used such a system as epoll (http://man7.org/linux/man-pages/man7/epoll.7.html), I know it is uses for another Go system for GPIO interaction here - https://godoc.org/github.com/kidoman/embd
https://i.imgur.com/HxCSXMw.png get this when running
Hi!
I catch this when I try to open memory range for GPIO access in /dev/mem:
open /dev/mem: permission deniedpanic: runtime error: index out of range
.
I try this script and add my user to group "gpio", but nothing changed.
How can I solve this problem?
I'm trying to convert some working Python code to run in go. The Python is as follows:
import RPi.GPIO as GPIO
import time
servoPIN = 13
GPIO.setmode(GPIO.BCM)
GPIO.setup(servoPIN, GPIO.OUT)
p = GPIO.PWM(servoPIN, 50) # GPIO 13 for PWM with 50Hz
p.start(2.5) # Initialization
try:
while True:
p.ChangeDutyCycle(5)
time.sleep(0.5)
p.ChangeDutyCycle(7.5)
time.sleep(0.5)
p.ChangeDutyCycle(10)
time.sleep(0.5)
p.ChangeDutyCycle(12.5)
time.sleep(0.5)
p.ChangeDutyCycle(10)
time.sleep(0.5)
p.ChangeDutyCycle(7.5)
time.sleep(0.5)
p.ChangeDutyCycle(5)
time.sleep(0.5)
p.ChangeDutyCycle(2.5)
time.sleep(0.5)
except KeyboardInterrupt:
p.stop()
GPIO.cleanup()
This Python code works. The servo moves constantly.
So I tried translating the code to Go using go-rpio. I got to this:
package main
import (
"fmt"
rpio "github.com/stianeikeland/go-rpio"
"time"
)
const PWM_PIN_NUMBER = 13
func main() {
err := rpio.Open()
if err != nil {
panic("Opening the pin goes wrong")
}
defer rpio.Close()
pin := rpio.Pin(PWM_PIN_NUMBER)
fmt.Println(pin)
pin.Mode(rpio.Pwm)
pin.Freq(50)
pin.DutyCycle(0, 50)
for {
fmt.Println(5)
pin.DutyCycle(uint32(5), 50)
time.Sleep(1 * time.Second)
fmt.Println(7)
pin.DutyCycle(uint32(7), 50)
time.Sleep(1 * time.Second)
fmt.Println(10)
pin.DutyCycle(uint32(10), 50)
time.Sleep(1 * time.Second)
fmt.Println(12)
pin.DutyCycle(uint32(12), 50)
time.Sleep(1 * time.Second)
fmt.Println(10)
pin.DutyCycle(uint32(10), 50)
time.Sleep(1 * time.Second)
}
}
The code runs, but the servo doesn't move at all.
Does anybody know what I'm doing wrong here?
The URL on the bottom of the README that should refers to create_gpio_user_permissions.py
(https://github.com/waveform80/rpi-gpio/blob/master/create_gpio_user_permissions.py) is broken, the owner remove the containing repo
It's this package working with the newly released raspberry pi pico controllet?
I've launched code on my raspberry pi 3b+ which is simillar to this https://github.com/stianeikeland/go-rpio/blob/master/examples/pwm/pwm.go
on my raspberry pi 3b+
func main() {
err := rpio.Open()
if err != nil {
os.Exit(1)
}
defer rpio.Close()
pin := rpio.Pin(7)
pin.Mode(rpio.Pwm)
pin.Freq(60*60)
pin.DutyCycle(0, 60)
// the LED will be blinking at 60Hz
// (source frequency divided by cycle length => 60*60/60 = 2000)
}
iirc it was exactly like this. After running it ssh freezed and after restarting raspberry, wont boot again. Do you know what could be the problem?
Line 214 in 896db2e
WritePin
, I think it should be fixed to:if (mem[levelReg] & (1 << uint8(pin & 31))) != 0 {
Hello, could a new tag be made? So RPI 4 works accordingly. Right now using:
github.com/stianeikeland/go-rpio/v4 v4.4.1-0.20200705092735-acc952dac3eb
also works for my modules file, but would be nice to have a more common way to approach this
When I lauch simple test,
I get error on rpio.Open()
-> Operation not permitted
I run golang program on root.
The kernel is Linux ubuntu 5.4.0-1026-raspi
Any idea about it.
Are there any plans for rotary encoder support?
Looking at SetDutyCycle() the use of mark/space is hard-coded. Is there a reason the default algorithm is being overridden? Would it be possible to add support for explicitly setting which algorithm should be used?
It would be great if it support other boards (orange pi, banana pi, etc)
Will this project support I2C communication ?
Hi. Is there an event model for this, or do we loop / state machine it for reading multiple inputs?
Thanks!
Tested on Raspberry Pi Zero W
OS Version: RASPBIAN STRETCH LITE (Release Date: 2018-06-27)
Kernel Version: Linux raspberrypi 4.14.52+ #1123 Wed Jun 27 17:05:32 BST 2018 armv6l GNU/Linux
Go Version: go1.10.3 linux/arm
Problems: I connect to pi via ssh, system freeze after initialize GPIO, but the same code works well on Raspberry Pi 3 which has the same OS Version, Kernel Version and Go Version.
sample code:
const (
io1 = uint8(5)
rst = uint8(13)
intIn = uint(26)
intOut = uint(21)
)
var outPin rpio.Pin
var inPin rpio.Pin
func startGPIO() {
err := rpio.Open()
if err != nil {
log.Fatal(err)
}
log.Info("open rpio successfully")
io1Pin := rpio.Pin(io1)
io1Pin.Output()
io1Pin.Low()
rstPin := rpio.Pin(rst)
rstPin.Output()
rstPin.High()
outPin = rpio.Pin(intOut)
outPin.Input()
outPin.Detect(rpio.FallEdge)
inPin = rpio.Pin(intIn)
inPin.Output()
inPin.High()
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.