Please help I am sending from my Android phone over UDP a Command ON of OFF which the PI should then switch the LED opn or OFF
at BCM pin 18 ,I run my script in Thonny with the debugger ,I can see the data bytes are correct in the variable window I see data as b'ON' or b'OFF' but the if statements always evaluate as false ,example in the ON case if I do step in debugging I can see the data[0] = 79 dec and it shows the 'O' the same for the data[1] but then it shows false and jump over switch ON the pin statement/command
what am I doing wrong
Code: Select all
while True:
data,addr = sock.recvfrom(1024)
if data[0] == 'O' and data[1] == 'N':
GPIO.output(18,ON)
elif data[0] == 'O' and data[1] == 'F' and data[2] == 'F':
GPIO.output(18,OFF)
elif data[0] == '#':
sock.close
sys.exit()