Closed foffer closed 8 years ago
Just for clarification, what branch are you using?
I'm using v.2.0.beta4. Not actually sure what branch I'm on. How would i see that?
The develop branch is a bit a head of master, so just wanted to know where to look, looks like the issue is the same in both places. PiPiper::Pin just caches value, so unless you specifically tell it to read from the gpio it will just used the cached value. So in your case I believe if you add a pin.read
after the update_value it should work.
Ahh, awesome, that worked! Thanks
In Ruby 2.1.2 on the Raspberry Pi B model using the Pry console (tested in IRB as well) Doing this:
pin = PiPiper::Pin.new(:pin => 18, :direction => :out)
correctly initialises the pin.pin.on / .off
works correctly. But when callingpin.value
it always returns 0. I've tried it using theupdate_value
method instead of the on / off method, but the.value
return is the same.[3] pry(main)> pin = PiPiper::Pin.new(:pin => 18, :direction => :out)
=> #<PiPiper::Pin:0x1cdd648 @direction=:out, @invert=false, @last_value=nil, @pin=18, @pull=:off, @trigger=:both, @value=0>
[4] pry(main)> pin.value
=> 0
[5] pry(main)> pin.update_value(1)
=> 1
[6] pry(main)> pin.value
=> 0
[7] pry(main)>