Sep-04-2021, 04:37 PM
making a simple remote radio control program. radio listens for packets
and if none received, keep listening. Im needing it to check if transmitted strings
(onset and unset as custom string triggers) match as my "commands" to control
electrical relay on or off... and if they dont match my 2 commands (else) just decode
string as ascii text and print the text. cannot get it to recognize my elif lines...
and if none received, keep listening. Im needing it to check if transmitted strings
(onset and unset as custom string triggers) match as my "commands" to control
electrical relay on or off... and if they dont match my 2 commands (else) just decode
string as ascii text and print the text. cannot get it to recognize my elif lines...
while True: packet = rfm9x.receive() if packet is None: led.value = False print("Received nothing! Listening again...") elif packet is onset: print("its now on") elif packet is unset: print("its now off") else: led.value = True print("Received (raw bytes): {0}".format(packet)) packet_text = str(packet, "ascii")