import RPi.GPIO as GPIO
from socket import *
from time import ctime
import time
host = '192.168.1.100'
port = 8000
buffsize = 1000
ADDR = (host,port)
server = socket(AF_INET,SOCK_STREAM)
server.bind(ADDR)
server.listen(3)
GPIO.setmode(GPIO.BOARD);
GPIO.setup(7,GPIO.OUT)
GPIO.output(7,0)
print('Wait for connection ...')
client,addr = server.accept()
print("Connection from :",addr)
while True:
string_recv = client.recv(buffsize).decode()
print(string_recv)
press_time = float(string_recv)
GPIO.output(7,1)
time.sleep(press_time)
GPIO.output(7,0)
client.close()
GPIO.cleanup()