开源硬件学习之:课程01:板载传感器信息获取
(2022-05-17 16:44:36)分类: 研究-学习 |
https://mp.weixin.qq.com/s/Zk5sbSETjuS1NphlyG27Yw
【公众号:蘑菇云创造】
display.scroll('Hello
World')#显示滚动文字
diaplay.scroll(temperature())
sleep(100)
if temperature()<30:
display.scroll('OK')
else:
display.scroll('NO')
if temperature()<30:
display.show(Image.Happy)
else:
display.show(Image.Sad)
使用编辑软件 BXY Python Editor
配套浙江版教材
'''
[课程01:板载传感器信息获取]
实践目标:
熟悉microbit主控板显示屏的使用
可以使用板载温度传感器获取环境温度信息
根据获取的温度信息,做判断并显示输出
知识目标:
编写python程序控制硬件
display模块,及不同方法、参数使用
temperature函数读取温度
while循环,延时等待sleep
知识链接:
板载功能-光线、温度传感器,加速度计、蓝牙、电子罗盘、磁力计
'''
#001
'''
from microbit import
*
#导入所有microbit自带库文件
display.scroll('Hello
World')#显示滚动文字
# 循环显示
display.scroll(string,loop=True)
display.scroll('Hello
World',loop=True)#持续显示滚动文字
'''
#02
'''
from microbit import
*
while True:
'''
#03 获取温度数据
emperature()
#sleep(50)
50毫秒
'''
from microbit import
*
while True:
'''
#04 项目拓展
from microbit import
*
while True:
#microbit 内置图案
'''
Image.Happy#笑脸
Image.Sad#难过
Image.HEART#爱心
....
display.show()#显示图案
from microbit import
*
display.show(Image.Happy)
#拓展 温度低于30,笑脸;否则哭脸
from microbit import
*
while True:
#总结:
内置LED方法:
.scroll(string)
滚动显示字符
.show(image)
显示图案
.set_pixel(x,y,value)设置X行Y列的LED等亮度,范围0--9
.clear()
关闭全部LED灯
指南针传感器compass模块说明
get_x()X
读取X方向的值
get_y()Y
读取Y方向的值
get_z()Z
读取Z方向的值
1、温度传感器
获取温度值
2、循环 while
True
3、点阵显示
display.scroll() ;dispaly.show()
什么是传感器?
非接触式红外温度传感器、心电检测传感器、环境温度传感器、光线传感器
传感器(sensor)用来测量和感知物体或环境属性,把被测的物理信号转换成电信号,以便通讯技术传递和收集。
传感器可以理解为模拟人类五官(视、味、听、嗅、触)去感知物理世界的一种物理装置。
'''
前一篇:近期要学习的方向
后一篇:20220518随想