As can be seen below, I have been getting very strange results:
Voltage | Pin | Mode | Value returned
3.3 v GPIO:0 Pullup 1
3.3 v GPIO:0 Float 1
3.3 v GPIO:2 Pullup 1
3.3 v GPIO:2 Float 1
0 v GPIO:0 Pullup 1
0 v GPIO:0 Float 1
0 v GPIO:2 Pullup 1
0 v GPIO:2 Float 1
This is the code that I ran:
function readpin (pin, mode)
-- Mode = 0 means float. Mode = 1 means pullup.
gpio.mode(pin, gpio.INPUT, mode)
print("PIN" .. pin .. "=" .. gpio.read(pin) .. ", in mode: " .. mode)
end
readpin(0, 0)
readpin(0, 1)
readpin(2, 0)
readpin(2, 1)
The code returned these results (for both 3.3 v and 0 v):
PIN0=1, in mode: 0
PIN0=1, in mode: 1
PIN2=1, in mode: 0
PIN2=1, in mode: 1
I have tried this with build 20150118 and build 20150108.
I must be doing something wrong. Any hints?