Advertisement
thomazrb

Leitura dos dados e conversão de coordenadas.

Oct 24th, 2017
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: iso-8859-1 -*-
  3. import serial
  4. import math
  5.  
  6. # Iniciando conexao serial
  7. comport = serial.Serial('/dev/cu.usbmodem1421', 9600)
  8.  
  9.  
  10. while 1:
  11.     linha=comport.readline()
  12.     vetorAngRaio = map(int, linha.split())
  13.     angulo = vetorAngRaio[0]
  14.     raio = vetorAngRaio[1]
  15.     x = raio * math.cos(math.radians(angulo))
  16.     y = raio * math.sin(math.radians(angulo))
  17.     print 'x: %s' % (x)
  18.     print 'y: %s' % (y)
  19.  
  20. # Fechando conexao serial
  21. comport.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement