RasPiArduino icon indicating copy to clipboard operation
RasPiArduino copied to clipboard

pinMode INPUT_PULLUP does not seem to work

Open marcmerlin opened this issue 6 years ago • 3 comments
trafficstars

I get output to work, I can toggle an LED, but I can't read a switch on port 4, which I can read from python just fine.

Here's the code I used, I see no change when I push the switch. Using a voltmeter it seems that

GPIO.setup(4, GPIO.IN, pull_up_down=GPIO.PUD_UP)

works in python, but

pinMode(4, INPUT_PULLUP)

does not work in the arduino layer.

Further testing shows that digitalRead does work after that, but I have to add a pull up resistor on my button to make up for the missing one in software (when using the arduino layer)

marcmerlin avatar Apr 19 '19 21:04 marcmerlin

I tested this on rPi 0W and rPi B+

marcmerlin avatar Apr 22 '19 15:04 marcmerlin

https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf should be used to check port numbers to fix this

marcmerlin avatar Apr 22 '19 18:04 marcmerlin

Page 90 of the PDF says that GPIO defines start at address 0x7E200000 but I can't find that address anywhere in the code: polgara:/tmp/RasPiArduino$ grep -ri 7E20 . polgara:/tmp/RasPiArduino$

Similarly, no luck with INPUT_PULLUP:

polgara:/tmp/RasPiArduino$ grep -r INPUT_PULLUP .
./cores/piduino/Arduino.h:#define INPUT_PULLUP    0x10
polgara:/tmp/RasPiArduino$ 

It's a single define that never gets used anywhere :-/

marcmerlin avatar Apr 22 '19 18:04 marcmerlin