title: How do I close or reset via arduino code?
body: <p>Well I want to print what has data in arduino right? I already tried with ser.close () as it is in the code and it does not work, it's the printe when I reboot the arduino, doing the whole process of pressing the button on the arduino. I would like to know how to reset or otherwise close the correct way for you to start the code.</p>
  
  <pre><code>def getSerialData(self):
  
      lines=b''
  
      with serial.Serial('COM5',9600) as ser:      
          while (ser.inWaiting()&lt;0): #Do while loop waiting for data 
              time.sleep(0.1)
          tempo = 20.0
          endtime=time.time()+tempo
          time.sleep(tempo-15.0)
          print("tempo")
          while (time.time()&lt;endtime):
              print("entrou")
              time.sleep(0.1)
              line = ser.readline()
              #line = line.encode("utf-8")
              lines += line
              #lines += bytes(line, 'utf-8')
      ser.close()
      print("saiu")
      lin = lines.split()
      print(lin)
  </code></pre>