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
    Aug 4 '15 at 8:42
  • and include the code Aug 4 '15 at 8:56
  • @albal You have it in tags.
    – Nicolas
    Aug 4 '15 at 10:11
  • I don't see code there :P Aug 4 '15 at 10:13
  • Just updated the post.
    – Nicolas
    Aug 4 '15 at 10:14
1

Use loop

while(param):
    whatever_to_do()

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.