SHARE
TWEET

Untitled

a guest Nov 19th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. import serial
  3.  
  4. try:
  5.     arduino = serial.Serial("/dev/ttyACM0",timeout=1)
  6. except:
  7.     print('Please check the port')
  8.  
  9. """Initialising variables"""
  10. VARIABLES A INIT
  11.  
  12. """Receiving data and storing it in a list"""
  13. while count<3:
  14.     rawdata.append(str(arduino.readline()))
  15.     count+=1
  16. print(rawdata)
  17.  
  18. def clean(L):#L is a list
  19.     newl=[]#initialising the new list
  20.     for i in range(len(L)):
  21.         temp=L[i][2:]
  22.         newl.append(temp[:-5])
  23.     return newl
  24.    
  25. cleandata=clean(rawdata)
  26.  
  27. def write(L):
  28.     file=open("data.txt",mode='w')
  29.     for i in range(len(L)):
  30.         file.write(L[i]+'\n')
  31.     file.close()
  32.  
  33. write(cleandata)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top