Code: Select all
import serial
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(24, GPIO.OUT)
ser = serial.Serial("/dev/ttyAMA0", 9600, timeout=1)
while 1:
x = ser.read()
if x == "H":
GPIO.output(24, GPIO.HIGH)
if x == "L":
GPIO.output(24, GPIO.LOW)