Giter Club home page Giter Club logo

Comments (6)

arnlen avatar arnlen commented on August 26, 2024 1

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.

zsyed91 avatar zsyed91 commented on August 26, 2024 1

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.

zsyed91 avatar zsyed91 commented on August 26, 2024

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:

  1. Led @ 17 is off
  2. Instantiate pin with PiPiper and do pin.on.
  3. Led @ 17 is now on
  4. pin.off
  5. 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.

elmatou avatar elmatou commented on August 26, 2024

tell us also which version of PiPiper you are using.

from pi_piper.

arnlen avatar arnlen commented on August 26, 2024

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.

arnlen avatar arnlen commented on August 26, 2024

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)

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.