I'm using a Raspberry Pi 2.

Part of my project requires the Pi to activate relays, for which I intend to make a pin high for a while and then return to low.

However once I set a pin to high, it does not return to low


while 1:

The loop executed regularly as I can see the test message printed.

The only way the pin resets is if I run GPIO.cleanup() on start of the program execution.

enter image description here enter image description here

  • The pin state changes to high ie give 3.3 v as soon the setup is done to make it an output pin . any change after that does to effect the state of the pin – Jude Mar 19 '16 at 8:52
  • You have presented no evidence that the pin does not go low. You have presented evidence that the relay is not operated as you expect it to operate. Given that we don't know how the relay works it is safest to remove it from the Pi and post a link to the specifications of the relay. – joan Mar 19 '16 at 9:07
  • GPIO.setmode(BOARD) GPIO.setup(40,OUT) just with this line the state of the Pin 40 goes high . I verfied this just using a multimeter . before i the pin 40 is set to OUT it shows 0v DC and after 40 is set up as output it then i get 3.2V . in the while loop when i try setting the pin status to low and high alternatively . There is no change seen in the pin state. – Jude Mar 19 '16 at 9:31
  • A GPIO set an an output retains the last set state until explicitly changed by a new high or low setting. As for no change in the while loop I suggest the relay is causing that effect. Remove the relay connection and measure again. – joan Mar 19 '16 at 9:40
  • The relay is disconnected . Have been monitoring using the multimeter alone . Still the response is the same. – Jude Mar 19 '16 at 9:51

Please recheck used pin, it seems like you connect GPIO21 instead of GPIO16.
Pi pinout

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.