Python Beispiel zugefügt

This commit is contained in:
Honky 2016-01-15 21:18:26 +00:00
parent 000dcdab82
commit 01d5f4f606

View File

@ -48,4 +48,29 @@ Ein einfaches Beispiel in Shell-Skript:
: <source lang=bash>( echo -en '\x00\x00\x02\xA6'; for i in {1..226}; do echo -en '\x00\xFF\x00'; done ) | ncat --send-only --udp ledbeere 2342</source>
Das sollte alle LEDs auf grün stellen.
Ein einfaches Beispiel in Python:
<source lang=python>
import socket
from struct import *
HOST = 'ledbeere'
PORT = 2342
#header
data = [pack('b',0),pack('b',0), pack('!h',678)];
#farben für 226 leds
for i in range(0,226):
data.append(pack('BBB',255,255,255))
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.sendto("".join(data),(HOST,PORT))
s.close()
</source>
Das sollte alle LEDs auf weiß stellen.
[[Kategorie:Projekt]]