Skip to content

anonymous /arduinoReaderTest.py
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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
Something went wrong with that request. Please try again.