电子罗盘
python 编程:
创建实例
compass(port_num)
创建compass实例,port_num 可取值为thunbot.PORT_1,thunbot.PORT_2,thunbot.PORT_3,thunbot.PORT_4,thunbot.PORT_A,thunbot.PORT_B。
方法
get_azimuth()
获取方位角,返回值范围为:0° ~ 359°,0°代表正北方向(Y向前),90°代表正东,180°代表正南,270°代表正西
编程示范
import thunbot
import time
c1 = thunbot.compass(thunbot.PORT_2)
while 1:
print("angle:",c1.get_azimuth())
time.sleep(1)