Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ...Python Code(Server)...
- ctrCmd = ['Up','Down', 'ON', 'OFF']
- ...
- ...
- while True:
- print ("Waiting for connection")
- tcpCliSock,addr = tcpSerSock.accept()
- print ("...connected from :", addr)
- try:
- while True:
- data = ''
- data = tcpCliSock.recv().decode()
- print("This",data)
- if not data:
- print ("No Data",data)
- break
- if data == ctrCmd[0]:
- print("I am here")
- Servomotor.ServoUp()
- print ("Increase: ",Servomotor.cur_X)
- #tcpCliSock.send("Servo Increases".encode())
- if data == ctrCmd[1]:
- Servomotor.ServoDown()
- print ("Decrease: ",Servomotor.cur_X)
- #tcpCliSock.send("Servo Decreases".encode())
- if data == ctrCmd[2]:
- Servomotor.ledOn()
- print ("Led On")
- #tcpCliSock.send("Led On".encode())
- if data == ctrCmd[3]:
- Servomotor.ledOff()
- print ("Led Off")
- # tcpCliSock.send("Led Off".encode())
- except KeyboardInterrupt:
- Servomotor.close()
- GPIO.cleanup()
- tcpSerSock.close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement