David12412412 Posted August 1, 2020 Posted August 1, 2020 Armbianmonitor: http://ix.io/2sRS When I try to read the input on PA19 immediately goes to "1" even though there is no voltage being sent to the pin. Example: #!/usr/local/bin/python from pyA20.gpio import gpio from pyA20.gpio import port pin_to_circuit = port.PA19 gpio.init() gpio.setcfg(pin_to_circuit, gpio.OUTPUT) gpio.output(pin_to_circuit, 0) gpio.setcfg(pin_to_circuit, gpio.INPUT) print(gpio.input(pin_to_circuit)) I don't understand why this would put "1" with nothing even connected to the PA19 pin? Are there some settings I need to change to get PA19 working as a normal GPIO pin?
martinayotte Posted August 1, 2020 Posted August 1, 2020 4 hours ago, David12412412 said: I don't understand why this would put "1" with nothing even connected to the PA19 pin? Pretty normal : PA19 is shared also as TWI1-SDA which is an I2C bus provided on header, and there are some PullUps resistors already present on the OPiZero board. So, simply short PA19 to GND, you will see that your script will print "0". 1
David12412412 Posted August 1, 2020 Author Posted August 1, 2020 If i short PA19 to GND how will I detect any input on PA19 as it will always just show "0"?
David12412412 Posted August 2, 2020 Author Posted August 2, 2020 Is there any way to disable TWI1-SDA, so that PA19 just acts as a normal GPIO pin? (so that I can read inputs normally as i would on another GPIO pin)
martinayotte Posted August 2, 2020 Posted August 2, 2020 14 hours ago, David12412412 said: If i short PA19 to GND how will I detect any input on PA19 as it will always just show "0"? I didn't say to short to GND permanently, but simply to check that the input is working fine as normal GPIO ... 4 hours ago, David12412412 said: Is there any way to disable TWI1-SDA It is already disabled by default, unless you load an I2C DT overlay ...
David12412412 Posted August 2, 2020 Author Posted August 2, 2020 (edited) I'm still not really understanding how I go about using PA19 as a normal GPIO input port, so that I can check if an input has been received (such as from a push button). Shorting PA19 to GND just means the voltage goes straight to GND and doesn't get detected as an INPUT. I'm not sure if I'm asking my question in the wrong way? For example if I have a push button from 3.3V to PA19 how can I detect a push on the button? Circuit like this: 3.3V --------> Push Button ------->1k Resistor ------> PA19 Currently I cannot detect a push on this circuit because PA19 just shows "1" all the time for the input. Edited August 2, 2020 by David12412412
usual user Posted August 2, 2020 Posted August 2, 2020 On 8/2/2020 at 4:31 PM, David12412412 said: 3.3V --------> Push Button ------->1k Resistor ------> PA19 Error prone HW design with floating IO. Proper design with fixed IO states: VCC --------> Pullup Resistor ---| GND --------> Push Button -------+------> PA19 The pullup is already in place. Pressing the button will flip the IO from 1 to 0. 1
Gabriel Bastos Posted August 28, 2020 Posted August 28, 2020 Hello, Have u managed to PA19 work as input without reading HIGH level ?
martinayotte Posted August 29, 2020 Posted August 29, 2020 15 hours ago, Gabriel Bastos said: Have u managed to PA19 work as input without reading HIGH level ? What do you mean by "without reading HIGH level" ? PA19 has a PullUp resistor, so by default it will be read as HIGH. To read it as LOW, it need to be shorted to GND as mentioned earlier in this thread ...
Recommended Posts