Created
June 17, 2014 09:09
-
-
Save mba7/836f81fe932b58329fe5 to your computer and use it in GitHub Desktop.
Simple Serial Port Sender
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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