11111111111

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()

posted @ 2018-02-16 17:25  一桶白开水  阅读(1393)  评论(0编辑  收藏  举报