Demo entry 6337986

Light Server

   

Submitted by anonymous on Dec 10, 2016 at 01:09
Language: Python 3. Code size: 978 Bytes.

import socket
 
i2cLocation = '/dev/i2c-1'
controllerAdress = 0x0A
serverIP = '192.168.1.100'
serverPort = 3859
dataBuffer = 6
 
'''
def sendI2C(red, green, blue)):
   i2c.init(i2cLocation)
   i2c.open(controllerAddress)
 
   i2c.write(hex(red))
   i2c.write(hex(green))
   i2c.write(hex(blue))
 
   i2c.close()
'''
 
ledSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ledSocket.bind((serverIP, serverPort))
ledSocket.listen(1)
while 1:
    recivingData = True
    while recivingData:
        conn = ledSocket.accept()[0]
        data = conn.recv(dataBuffer)
        conn.close()
        if data:
            print(data)
            #colorList = data.split(' ', 3)
            # sendI2C(int(colorList[0]), int(colorList[1]), int(colorList[2]))
            #print('red is ' + colorList[0])
            #print('green is ' + colorList[1])
            #print('blue is ' + colorList[2])
        else:
            recivingData = False

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).