Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import serial
- import matplotlib.pyplot as plt
- L1=[]
- L2=[]
- values = []
- serialArduino=serial.Serial('com5',9600)
- def plotValues():
- plt.title('Grafic senzor umiditate')
- plt.grid(True)
- plt.ylabel('Valoare')
- plt.plot(values, 'rx-', label='Senzor umiditate=' +v+'L1='+L1+'L2'+L2
- ,color='blue')
- plt.legend(loc='upper left')
- plt.xlabel('Timp')
- for i in range(0,40):
- values.append(0)
- while True:
- while(serialArduino.inWaiting()==0):
- pass
- valueRead,L1,L2=serialArduino.readline().decode('utf8').split(';')
- try:
- valueInInt=int(valueRead)
- print(valueInInt)
- if valueInInt <=1024:
- if valueInInt >=0:
- value.append(valueInInt)
- values.pop(0)
- drawnow(plotValues)
- else:
- print("Numar negativ")
- else:
- print("Valoare venita de la Arduino e prea mare")
- except ValueError:
- print("Valoarea nu poate fi parsata")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement