Skip to content

Instantly share code, notes, and snippets.

@mba7
Created June 17, 2014 09:09
Show Gist options
  • Save mba7/836f81fe932b58329fe5 to your computer and use it in GitHub Desktop.
Save mba7/836f81fe932b58329fe5 to your computer and use it in GitHub Desktop.
Simple Serial Port Sender
import serial
import random, time, math
ser = serial.Serial(0, 38400)
incycle = 0
while True:
t = int(random.randint(60, 80) * (1 + math.sin(incycle)))
print "sent data:", t
x = ser.write(chr(t))
time.sleep(0.2)
incycle += 0.01
if incycle >= 2 * math.pi:
incycle = 0
ser.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment