thomazrb icon

Leitura dos dados e conversão de coordenadas.

thomazrb | PRO | 10/24/17 10:26:12 PM UTC | 0 ⭐ | 564 👁️ | Never ⏰ | []
Python |

480 B

|

None

|

0 👍

/

0 👎

#!/usr/bin/python
# -*- coding: iso-8859-1 -*-
import serial
import math
 
# Iniciando conexao serial
comport = serial.Serial('/dev/cu.usbmodem1421', 9600)
 
 
while 1:
    linha=comport.readline()
    vetorAngRaio = map(int, linha.split())
    angulo = vetorAngRaio[0]
    raio = vetorAngRaio[1]
    x = raio * math.cos(math.radians(angulo))
    y = raio * math.sin(math.radians(angulo))
    print 'x: %s' % (x)
    print 'y: %s' % (y)
 
# Fechando conexao serial
comport.close()

Comments