1

In one of scripts we are sending HIGH to pin 17,

import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)
GPIO.output(17,GPIO.HIGH)

And in another script reading GPIO as,

import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)
GPIO.setup(17,GPIO.IN)
gpioInput = GPIO.input(17)
print(gpioInput)

But, it shows wrong values i.e while led light is on, value is coming as false. Anything seems missing here?

1

The first script sets the GPIO as an OUTPUT and writes 1.

The second script sets the GPIO as an INPUT which means the LED will be in an unknown state as it is not actively driven.

I would expect the second script to give a warning about channel already in use.

  • Yes, actually it shows same warning as you mentioned. but also gives output. So what would be correct steps to read pin 11? – BaSha Jan 28 '16 at 10:47
  • With RPi.GPIO? You will have to read the GPIO in the same script as you write the GPIO. – joan Jan 28 '16 at 10:56
  • ...actually it may work if you run the read script in a loop and launch that first. – joan Jan 28 '16 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.