# Importing library import csv import pandas as pd import serial import time import matplotlib.pyplot as plt # make sure the 'COM#' is set according the Windows Device Manager ser = serial.Serial('insert_device_com', 9600, timeout=1) time.sleep(2) data = [] for i in range(100): line = ser.readline() # read a byte string if line: string = line.decode() # convert the byte string to a unicode string num = float(string) # convert the unicode string to an int num2 = int(num) data.append(num2) # add int to data list ser.close() # build the plot plt.plot(data) plt.xlabel('Time[ms]') plt.ylabel('Sound[dB]') plt.title('Sound vs. Time') plt.show()