import serial
import matplotlib.pyplot as plt

ser = serial.Serial('/dev/ttyACM0',9600)
print(ser.name)

ser.write('r')
#s = ser.read(100)
#print(s)

## Arrays for data
raw = []
maf = []
iir = []
fir = []

for i in range(99):
    serial_line = ser.readline()
    # print serial_line
    data_read = serial_line.split(", ")
    print(i)
    print(float(data_read[1]), float(data_read[2]), float(data_read[3]), float(data_read[4]))
    raw.append(float(data_read[1]))
    maf.append(float(data_read[2]))
    iir.append(float(data_read[3]))
    fir.append(float(data_read[4]))

plt.plot(raw, label='raw')
plt.plot(maf, label='maf')
plt.plot(iir, label='iir')
plt.plot(fir, label='fir')
plt.legend()
plt.show()

