Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

realtime graph using serial data

I am trying to create realtime graph using serial data input.I am getting six values from serial data and going to use this for x-axis.The value for y-axis should be constant and y-axis values are (1,2,3,4).

the code I have been tried is :

import numpy as np 
import matplotlib.pyplot as plt  
import serial

s=serial.Serial('/dev/ttyACM0',9600)

while True:
    z=s.readline()
    print(z)
    x = (z)
    y = (1,2,3,4)
    plt.title("sine wave form") 
    # Plot the points using matplotlib 
    plt.plot(x, y) 
plt.show() 

I can't make it real time. How to do that?

Comments