Comments (6)
It works!
My bad, I was misunderstanding the pin number: I though the pin number was the number in the order of the GPIO (from 1 to 40), but in fact I understand there is no relation between the position of the pin, and its number.
The GPIO 17 pin is on the place 11, but it's still called "17".
Conclusion:
- still works on Jessie
- still requires
sudo
Thanks for your help! :)
from pi_piper.
Ah yes, I was thinking that might be it. I will update the documentation to make this clearer. I noticed that others have had that same misunderstanding. I am glad that it works for you though!
from pi_piper.
Haven't gotten a chance to upgrade to jessie yet so I am not sure. It seems like the changes in jessie mean you don't need sudo access for GPIO anymore. But to be safe, did you try running your script or irb session using rvmsudo
?
I can take a look but AFAIK pin.on
and pin.off
will always return 1 if it was successful. So the "state" is correct here, when you do pin.off?
. Just to clarify, is this your workflow:
- Led @ 17 is off
- Instantiate pin with
PiPiper
and dopin.on
. - Led @ 17 is now on
pin.off
- Led @ 17 is still on?
If you say that the led is already on before the script, then either your wiring is done in a way that power is always getting to the led or something else has locked the pin. In the latter case, that would definitely be a bug if it isn't throwing an error.
from pi_piper.
tell us also which version of PiPiper you are using.
from pi_piper.
Here is what I notice:
- connected to 3.3V pins (pin #1 or #17), the LED if on when the board is powered on.
- connected to another pin (GPIO 17 on pin #11), the LED is off on startup.
Then:
# same as rvmsudo but for rbenv
rbenv sudo irb
irb(main):001:0> require 'pi_piper'
=> true
irb(main):002:0> include PiPiper
=> Object
irb(main):005:0* pin = PiPiper::Pin.new(:pin => 13, :direction => :out)
=> #<PiPiper::Pin:0x5665da18 @pin=13, @direction=:out, @invert=false, @trigger=:both, @pull=0, @last_value=nil, @value=0>
# LED is off
irb(main):006:0> pin.on?
=> false
irb(main):007:0> pin.on
=> 1
# LED is still off
irb(main):008:0> pin.on?
=> false
I'm using pi_piper (2.0.0)
from pi_piper.
If I try to use pi_piper without sudo
:
irb(main):004:0* pin = PiPiper::Pin.new(:pin => 11, :direction => :out)
bcm2835_init: Unable to open /dev/mem: Permission denied
Errno::EACCES: Permission denied @ rb_sysopen - /sys/class/gpio/gpio11/direction
from /home/pi/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/pi_piper-2.0.0/lib/pi_piper/bcm2835.rb:61:in `write'
from /home/pi/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/pi_piper-2.0.0/lib/pi_piper/bcm2835.rb:61:in `pin_direction'
from /home/pi/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/pi_piper-2.0.0/lib/pi_piper/bcm2835.rb:45:in `pin_output'
from /home/pi/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/pi_piper-2.0.0/lib/pi_piper/pin.rb:56:in `initialize'
from (irb):4:in `new'
from (irb):4
from /home/pi/.rbenv/versions/2.3.0/bin/irb:11:in `<main>'
irb(main):005:0>
from pi_piper.
Related Issues (20)
- Is Pi_Piper ready for RPi 3 ? HOT 4
- Pin.on?/.off? notworking ?
- Seg fault HOT 1
- Gem Version 2.0? HOT 1
- Output pin turns back on after exit HOT 2
- Resource Not Available HOT 2
- Yet Another Problem HOT 9
- Sorry if it's a noob question... HOT 9
- Can't read correct values from a rpi B 1 HOT 5
- One-wire monitoring with PiPiper HOT 2
- Why is lib/pi_piper/driver.rb empty method definitions? HOT 3
- OpenWRT? HOT 1
- tegv
- Behavior of after/watch not as expected HOT 1
- Example of i2c
- Issue with ffi gem dependency
- RPi 3+ 64bits HOT 1
- Race condition on non root user when PiPiper::Pin.new HOT 1
- pi_piper with gtk aborts ruby interpreter (RPi Raspbian Stretch) HOT 1
- Examples with tests
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pi_piper.