回到首页 返回首页
回到顶部 回到顶部
返回上一页 返回上一页

【Mind+Python】地球那么大,我想量一量 简单

头像 天然闪队 2021.09.23 717 0

我们的家园地球(Earth)是太阳系由内及外的第三颗行星,距离太阳约1.496亿千米(1天文单位)。地球自西向东自转,同时围绕太阳公转。现有45.5亿岁,有一个天然卫星——月球,二者组成一个天体系统——地月系统。45.5亿年以前起源于原始太阳星云。
地球赤道半径6378.137千米,极半径6356.752千米,平均半径约6371千米,赤道周长约为40075千米,呈两极稍扁赤道略鼓的不规则的椭球体。地球表面积5.1亿平方千米,其中71%为海洋,29%为陆地。

地球那么大,我想量一量………

project-image

最近我们在玩滚轮测距仪,各种测量……..

很多路没有我们想象的那么长,也没有我们想象的那么短。

project-image

小区从东西长度2420米。

这样太不方便了,那就升级吧!

步骤1 方案

我们采用掌控板和计数传感器,来给这个给测距仪升级!HOHO!

步骤2 升级改造测距仪

拆开测距仪,准备安装传感器硬件。

project-image
project-image

1.如图所示用热熔胶固定强磁铁到滚轮上。

project-image

2.如图所示热熔胶固定安装霍尔传感器到测距仪上。

project-image
project-image

3D打印一个掌控板盒体,把它保护起来。

步骤3 材料表

材料清单

  • 掌控版 X1 链接
  • 扩展模块 X1 链接
  • 霍尔传感器 X1 链接
  • 强磁铁 X1
  • 3D打印控制壳 X1
  • X1

步骤4 编程

代码
/*!
 * MindPlus
 * mpython
 *
 */
#include <MPython.h>
#include <DFRobot_Iot.h>
#include <mPython_Weather.h>

// 动态变量
volatile float mind_n_LiCheng;
// 静态常量
const uint8_t imageMatrix[][288] = {
	{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0xc0,0x0,0x0,0x0,0x0,0x7f,0xfc,0x0,0x0,0x0,0x1,0xff,0xff,0x0,0x0,0x0,0x3,0xff,0xff,0xc0,0x0,0x0,0xf,0xff,0xff,0xe0,0x0,0x0,0x1f,0xff,0xff,0xf0,0x0,0x0,0x3f,0xff,0xff,0xf8,0x0,0x0,0x7f,0xff,0xff,0xfc,0x0,0x0,0x7f,0xff,0xff,0xfe,0x0,0x0,0xff,0xff,0xff,0xfe,0x0,0x0,0xff,0xff,0xff,0xff,0x0,0x1,0xff,0xff,0xff,0xff,0x0,0x1,0xff,0xff,0xff,0xff,0x80,0x1,0xff,0xff,0xff,0xff,0x80,0x3,0xff,0xff,0xff,0xff,0x80,0x3,0xff,0xff,0xff,0xff,0x80,0x3,0xff,0xff,0xff,0xff,0x80,0x3,0xff,0xff,0xff,0xff,0xc0,0x3,0xff,0xff,0xff,0xff,0xc0,0x3,0xff,0xff,0xff,0xff,0x80,0x3,0xff,0xff,0xff,0xff,0x80,0x3,0xff,0xff,0xff,0xff,0x80,0x1,0xff,0xff,0xff,0xff,0x80,0x1,0xff,0xff,0xff,0xff,0x0,0x1,0xff,0xff,0xff,0xff,0x0,0x0,0xff,0xff,0xff,0xff,0x0,0x0,0xff,0xff,0xff,0xfe,0x0,0x0,0x7f,0xff,0xff,0xfc,0x0,0x0,0x3f,0xff,0xff,0xfc,0x0,0x0,0x1f,0xff,0xff,0xf8,0x0,0x0,0xf,0xff,0xff,0xf0,0x0,0x0,0x7,0xff,0xff,0xe0,0x0,0x0,0x3,0xff,0xff,0x80,0x0,0x0,0x0,0xff,0xfe,0x0,0x0,0x0,0x0,0x1f,0xf8,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}
};
// 创建对象
DFRobot_Iot     myIot;
mPython_Weather myWeather;


// 主程序开始
void setup() {
	mPython.begin();
	myIot.wifiConnect("Redmi", "123456789");
	myWeather.init("server.mindplus.top", "31982666", "E6MtBcxQ");
	display.drawImage(72, 20, 48, 48, imageMatrix[0]);
}
void loop() {
	display.setCursorLine(1);
	display.printLine((String("天气") + String(myWeather.getWeather("weather", "101200101"))));
	delay(1000);
	display.setCursor(0, 16);
	display.print("测长:        米    ");
	if ((digitalRead(P8))) {
		mind_n_LiCheng += 1;
		display.setCursor(32, 16);
		display.print(mind_n_LiCheng);
		delay(1000);
	}
}

步骤5 测试

project-image

测试开始,天气数据通讯不成功。各种排除,测试…………

project-image

如图所示:测长数据有了!

project-image

数据终于出来了……….!

评论

user-avatar