0

Like above: how to force RPi to wait for data from UART and do not terminate the program ? I solved my problem with connection between RPi and BT Module and Arduino but the program I wrote is closing after receiving one bit.

import RPi.GPIO as GPIO
import serial import time
import sys
port=serial.Serial("/dev/ttyAMA0", baudrate=9600, timeout=100) BOARD=GPIO.BOARD
OUT=GPIO.OUT
HIGH=GPIO.HIGH
LOW=GPIO.LOW

GPIO.setwarnings(False)
GPIO.setmode(BOARD)
GPIO.setup(11, OUT)

port.write('1')

if(port.read() == '1'):
    GPIO.output(11, HIGH)
    time.sleep(1)
    GPIO.output(11, LOW)
    time.sleep(1)
    print "OK"

else:
    print "Fail"
    port.write('0')
6
  • It may help to specify what programming or scripting language you are using.
    – albal
    Commented Aug 4, 2015 at 8:42
  • and include the code Commented Aug 4, 2015 at 8:56
  • @albal You have it in tags.
    – Nicolas
    Commented Aug 4, 2015 at 10:11
  • I don't see code there :P Commented Aug 4, 2015 at 10:13
  • Just updated the post.
    – Nicolas
    Commented Aug 4, 2015 at 10:14

1 Answer 1

1

Use loop

while(param):
    whatever_to_do()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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