Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. ...Python Code(Server)...
  2. ctrCmd = ['Up','Down', 'ON', 'OFF']
  3. ...
  4. ...
  5. while True:
  6. print ("Waiting for connection")
  7. tcpCliSock,addr = tcpSerSock.accept()
  8. print ("...connected from :", addr)
  9.  
  10. try:
  11. while True:
  12. data = ''
  13. data = tcpCliSock.recv().decode()
  14. print("This",data)
  15.  
  16. if not data:
  17. print ("No Data",data)
  18. break
  19. if data == ctrCmd[0]:
  20. print("I am here")
  21. Servomotor.ServoUp()
  22. print ("Increase: ",Servomotor.cur_X)
  23. #tcpCliSock.send("Servo Increases".encode())
  24. if data == ctrCmd[1]:
  25. Servomotor.ServoDown()
  26. print ("Decrease: ",Servomotor.cur_X)
  27. #tcpCliSock.send("Servo Decreases".encode())
  28. if data == ctrCmd[2]:
  29. Servomotor.ledOn()
  30. print ("Led On")
  31. #tcpCliSock.send("Led On".encode())
  32. if data == ctrCmd[3]:
  33. Servomotor.ledOff()
  34. print ("Led Off")
  35. # tcpCliSock.send("Led Off".encode())
  36. except KeyboardInterrupt:
  37. Servomotor.close()
  38. GPIO.cleanup()
  39. tcpSerSock.close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement