#listen for a socket connection on port 1237 #if it comes, make the relay go high to turn on the #driveway flood lights # The socket connection will be coming from the web server #on 102 pi, but it could come from anywhere... import socket # Import socket module #import the library that allows us to access the GPIO pins #alias it to GPIO to make things simpler import RPi.GPIO as GPIO #Use the BCM pin numbering scheme GPIO.setmode(GPIO.BCM) #Turn off warnings on multiple programs playing with the pins.. GPIO.setwarnings(False) #set gpio pin 3 to be used as an output GPIO.setup(3, GPIO.OUT) s = socket.socket() # Create a socket object port = 1237 # Reserve a port for your service. s.bind(('192.168.0.101', port)) # Bind to the port while (1): s.listen(5) # Now wait for client connection. c, addr = s.accept() # Establish connection with client. GPIO.output(3,GPIO.HIGH) # fire off relay c.close() # Close the connection