muckypup wrote:I think I am missing something here...
From what I can gather the following should work, but catting value is not blocking and I seem to get a random 0 or 1 even though I have said I am only interested on a rising edge and I have nothing connected to the pin so should be 0 all the time.
# echo "18" > export
# cd gpio18
# echo "rising" > edge
# cat value
1
# cat value
0
Anyone have any idea what I am doing wrong?
Thanks
Steve
Why do you think the pin should read 0 with nothing connected?
It's an easy mistake to make though - the pin are high imedance inputs and will react to lots of wibbly wobbly stuff nearby...
If you want to ensure it reads 0 with nothing connected then either use an external resistor to tie it to 0v, or enable the internal pull-down resistors..
Install wiringPi, then
gpio -g mode 18 down
will enable the internal pull-down resistor.
You can also:
gpio -g wfi 18 rising
which will setup and wait for the rising interrupt on pin BCM_GPIO 18 to save all that bash typing
You can test it easilly too - if you have 2 windows open, and in one, wait for the interrupt, then in another: gpio -g mode 18 up
that will change the pull-down into a pull-up resistor and trigger the edge.
http://wiringpi.com/
-Gordon