Skip to content

unable to control GPIO from python #2

Description

@ariutti

Super useful tool,
thank you so much as always.

Just an issue I've with my RaspberryPi 3 model B+ after compiled, installed the script and run it as a service: I'm not able to check GPIO status from my python script anymore while shortening the pin to ground correctly shutdown the Pi (so, I think, the GPIOs are correctly working)

My system is:

  Operating System: Raspbian GNU/Linux 10 (buster)
            Kernel: Linux 4.19.50-v7+
      Architecture: arm

This is the python code I've always used to test my GPIOs with success:

import RPi.GPIO as GPIO
import time

myPins = [40, 36] 
PAUSE = 0.025

GPIO.setmode(GPIO.BCM)

for pin in myPins:
	GPIO.setup( pin, GPIO.IN, pull_up_down=GPIO.PUD_UP )

try:
	while(1):
		#read the input
		values = [GPIO.input(pin) for pin in myPins]
		print( values )
		time.sleep(PAUSE)
except:
	print("cleanup")
	GPIO.cleanup()

In the output I always see:

[1, 1]
[1, 1]
[1, 1]
[1, 1]
[1, 1]
[1, 1]
[1, 1]
[1, 1]

even if I'm actually shortening GPIO 21 an GPIO16 woth GND. Why?

Any ideas?
Thank you so much

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions