-1
    import RPi.GPIO as GPIO
    import time

    def wait():

        if GPIO.input(5)==1:
         print ("ack rcvd")
         return



  GPIO.setmode(GPIO.BOARD)
  GPIO.setwarnings(False)



  GPIO.setup(8,GPIO.OUT,initial=0)
  GPIO.setup(3,GPIO.OUT,initial=0)
  GPIO.setup(5,GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
  GPIO.setup(7,GPIO.OUT,initial=0)


  print("BEGIN OF TRANSMISSION")

  GPIO.output(7,GPIO.HIGH)



      GPIO.output(8,GPIO.LOW);
      GPIO.output(3,GPIO.LOW);
      print ("p1")
      wait()
      GPIO.output(8,GPIO.LOW);
      GPIO.output(3,GPIO.HIGH);
      print ("p2")
      wait()
      GPIO.output(8,GPIO.HIGH);
      GPIO.output(3,GPIO.LOW);
      print ("p3")
      wait()
      GPIO.output(8,GPIO.HIGH);
      GPIO.output(3,GPIO.HIGH);
      print ("p4")
      wait()
      GPIO.output(8,GPIO.LOW);
      GPIO.output(3,GPIO.LOW);
      print ("p5")
      wait()
      GPIO.output(8,GPIO.LOW);
      GPIO.output(3,GPIO.HIGH);
      print ("p6")
      wait()


      GPIO.output(7,GPIO.LOW)
      print("END OF TRANSMISSION")

The above code is to initiate communication between raspberry pi and another device.

I have written the wait function to return the control to the transmission part if an acknowledgement signal is received at the input pin.

But the control is returned to the while loop even if the acknowledgement is not received and the transmission goes on. can anyone please help me in writing the acknowledgement function so as the control returns to the while loop only when acknowledgement signal is received at the input pin.?

  • You may wanna be more specific with the language, i.e. C/C++, Python, Java, etc., you wanna use on your program. – user91822 Nov 15 '18 at 2:03
  • I am using Python language for coding.... – jesvin palatty Nov 15 '18 at 2:08
  • But the control is returned to the while loop What while loop? I can't see one. I do see several random indentation levels. Is this the actual code you're running? – Dirk Nov 15 '18 at 2:30
  • Please ignore the indentations....I got it wrong while posting this question in thi forum.. – jesvin palatty Nov 15 '18 at 8:51
  • ignore the indentations You can't actually do that with Python. And what about the while loop? I think it's best if you post some proper code. – Dirk Nov 15 '18 at 9:54

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.