5913|12

356

帖子

0

TA的资源

一粒金砂(中级)

楼主
 

我的newbit 指南针 [复制链接]

 
 
本帖最后由 ihalin 于 2017-4-5 22:22 编辑

我的newbit指南针
先按A键 检验指南针(画圈检验)

然后通过clock方式显示出方向

1点方向
  1. from microbit import *
  2. #  指南针 校验
  3. compass.calibrate()

  4. #利用image的clock时钟显示的来大概指示方向
  5. while True:
  6.     sleep(100)
  7.     needle = ((15 - compass.heading()) // 30) % 12
  8.     display.show(Image.ALL_CLOCKS[6+needle])
复制代码




此内容由EEWORLD论坛网友ihalin原创,如需转载或用于商业用途需征得作者同意并注明出处
]
查看本帖全部内容,请登录或者注册

最新回复

有一点儿意思。  详情 回复 发表于 2017-4-8 10:32

赞赏

1

查看全部赞赏

点赞 关注
 
 

回复
举报

356

帖子

0

TA的资源

一粒金砂(中级)

沙发
 
固件 microbit.hex (651.66 KB, 下载次数: 23)
 
 
 

回复

6419

帖子

16

TA的资源

版主

板凳
 
没看出怎么指南来啊

点评

1点方向  详情 回复 发表于 2017-4-5 20:48
个人签名training
 
 
 

回复

356

帖子

0

TA的资源

一粒金砂(中级)

4
 
白丁 发表于 2017-4-5 19:51
没看出怎么指南来啊

1点方向
 
 
 

回复

1万

帖子

25

TA的资源

版主

5
 
这个比较有趣。
 
 
 

回复

1万

帖子

25

TA的资源

版主

6
 
这个指示的方向是北方吧,应该叫指北针

点评

确实是指北,习惯了指南,我改过来  详情 回复 发表于 2017-4-5 22:05
 
 
 

回复

356

帖子

0

TA的资源

一粒金砂(中级)

7
 
dcexpert 发表于 2017-4-5 21:23
这个指示的方向是北方吧,应该叫指北针

确实是指北,习惯了指南,我改过来
 
 
 

回复

356

帖子

0

TA的资源

一粒金砂(中级)

8
 
本帖最后由 ihalin 于 2017-4-5 22:11 编辑
dcexpert 发表于 2017-4-5 21:23
这个指示的方向是北方吧,应该叫指北针

加个6-needle
display.show(Image.ALL_CLOCKS[6-needle])
 
 
 

回复

356

帖子

0

TA的资源

一粒金砂(中级)

9
 
compass的函数使用方法:

microbit.compass.calibrate()
Starts the calibration process. An instructive message will be scrolled to the user after which they will need to rotate the device in order to draw a circle on the LED display.

microbit.compass.is_calibrated()
Returns True if the compass has been successfully calibrated, and returns False otherwise.

microbit.compass.clear_calibration()
Undoes the calibration, making the compass uncalibrated again.

microbit.compass.get_x()
Gives the reading of the magnetic force on the x axis, as a positive or negative integer, depending on the direction of the force.

microbit.compass.get_y()
Gives the reading of the magnetic force on the x axis, as a positive or negative integer, depending on the direction of the force.

microbit.compass.get_z()
Gives the reading of the magnetic force on the x axis, as a positive or negative integer, depending on the direction of the force.

microbit.compass.heading()
Gives the compass heading, calculated from the above readings, as an integer in the range from 0 to 360, representing the angle in degrees, clockwise, with north as 0.

microbit.compass.get_field_strength()
Returns an integer indication of the magnitude of the magnetic field around the device.
 
 
 

回复

1248

帖子

67

TA的资源

纯净的硅(中级)

10
 
 
 

回复

1万

帖子

25

TA的资源

版主

11
 
  1. from microbit import *

  2. compass.calibrate()

  3. while True:
  4.     sleep(100)
  5.     needle = compass.heading() // 45
  6.     display.show(Image.ALL_ARROWS[3-needle])
复制代码



改了一个用箭头表示的指南针。

 
 
 

回复

1万

帖子

25

TA的资源

版主

12
 
把校正这一行可以删除,这样就不用每次启动都校正。而第一次系统会提示校正的。
 
 
 

回复

745

帖子

4

TA的资源

纯净的硅(初级)

13
 
有一点儿意思。
个人签名徐建
20091127
 
 
 

回复
您需要登录后才可以回帖 登录 | 注册

查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/10 下一条
有奖探索 | 和村田一起,深挖 GNSS 开发!
活动时间:即日起-5月11日
活动奖励:智能手环、螺丝刀套装、双肩包

查看 »

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

 
机器人开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网 1

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表