Created
February 12, 2013 06:29
-
-
Save anonymous/4760624 to your computer and use it in GitHub Desktop.
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 | |
import time | |
import string | |
# Change timeout so we can quickly see what's wrong | |
arduino = serial.Serial(port='/dev/cu.usbserial-A600egLQ', baudrate=115200, timeout=0.1) | |
print "Connected:", arduino.isOpen() | |
testList = [] | |
c = 0 | |
while (c < 10): | |
a = random.randint(50,150) | |
testList.append(a) | |
c+=1 | |
# Length will be 9 always (c<10 determines how many items we have) | |
length = len(testList) | |
points = 20 | |
writeString = str(length) + str(testList) + str(points) | |
print "Writing this string:", writeString | |
arduino.write(writeString) | |
d = 0 | |
dataList = [] | |
while (d < points): | |
readIn = arduino.readline() | |
# Print the actual string we get - maybe we don't get \r\n at the end | |
print repr(readIn) | |
point = string.translate(readIn, None, deletions='\r\n') | |
print point | |
dataList.append(point) | |
d+=1 | |
arduino.close() | |
maximum = max(dataList) | |
print 'The Maximum point returned is:', maximum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment