回到首页 返回首页
回到顶部 回到顶部
返回上一页 返回上一页
best-icon

【造作一夏 】基于Mind+掌控板PH电子试纸 简单

头像 rzegkly 2020.06.04 961 0
project-image

一、【项目介绍】

芒种是二十四节气中的第9个节气,更是干支历午月的起始;

时间点在公历每年6月6日前后,太阳到达黄经75°时。

芒种字面的意思是"有芒的麦子快收,有芒的稻子可种"。

在这个瓜果飘香的季节里,感谢大自然带给我们的美味的食物。

然而,当孩子们面对形形色色的饮料,喝什么样的水更健康?

今天我们设计基于Mind+掌控板PH电子试纸,和孩子一起测试下吧!

project-image

材料清单

  • 掌控板扩展板 X1 链接
  • 掌控板 X1 链接
  • RGB 全彩灯带 X1 链接
  • 模拟PH计 X1 链接
  • 乐高积木 X1
  • 3.7v锂电池 X1
project-image

二、【解决方案】

1、当按掌控板A按键,PH传感器开始检测液体,蜂鸣器发出测试音;

2、 当按掌控板B按键,PH传感器检测液体结束,蜂鸣器发出测试音; 根据不同数值,点亮不同的灯带数

3、 测自来水数值=0.24,PH=8,8个rgb灯被点亮;

4、测香皂水数值=0.25,PH=6,7个rgb灯被点亮 ;

5、测冰红茶数值=0.18,PH=4,3个rgb灯被点亮 ;

三、【作品演示】

四、【制作过程】

步骤1 安装软件:http://mindplus.cc 下载 Mind+_Win_V1.6.2_RC2.0 ;

project-image

步骤2 搭建测试实验台:

project-image

(1).分别利用乐高积木12*6砖,10*6砖为地基,4根柱子搭建测试台底座。


project-image

(2).分别2根13孔的梁和2根7孔搭建测试台架。

project-image

(3),将台底座和台架组装。

project-image

步骤3 编写程序环境配置

project-image

1、通过数据线连接掌控板和计算机,用管理员模式打开Mind+1.6.2,将Mind+切换为“上传模式”下,连接设备,选择串口com9;



project-image
project-image
project-image

2.扩展模块中,添加主控板:掌控板;显示器:RGB灯; 功能模块:多线程;

步骤4 程序编写

project-image

当按掌控板A按键,启动子线程1检测液体;当按掌控板B按键,启动子线程2检测液体结果。

当启动子线程1时,蜂鸣器发出测试音; 等待3s,显示时间沙漏图片。


project-image

当启动子线程2

蜂鸣器发出测试音; 根据不同数值,点亮不同的灯带数

测自来水数值=0.24,PH=8,8个rgb灯被点亮;

测香皂水数值=0.25,PH=6,7个rgb灯被点亮 ;

测冰红茶数值=0.18,PH=4,3个rgb灯被点亮 ;

project-image

五、【总结】

       周末,我和孩子一起制作一个《基于Mind+掌控板PH电子试纸》,由于孩子喜欢喝可乐饮料,通过PH电子试纸实验,让孩子发现问题 ,解决问题能力,然而在mind+扩展库传感器中,没有找到相关元器件,学习夏青老师(微笑的Rockets)PH实验,测到不同液体的数据,公式:液体数值=p0模拟数值/1024*5.0*3.5+0.12。

自来水:0.24;

冰红茶:0.18;

香皂水:0.25;

      为了体现出PH数值,液体数值扩大100倍,通过数学映射,将[17,24]——[4,9],通过掌控板显示出来!

     今天不仅是二十四节气——芒种,同时是第49个六五环境日,由于时间和网络的限制 ,将来通过物联网平台,我想带着孩子一起到周围河流测试酸碱度!

六、【资源】

project-image

1、模拟PH计使用方法

将pH传感器接到板载BNC接口,将板载PH2.0接口连接到掌控板的模拟口p0; 传感器的电极采用玻璃电极和参比电极组合在一起的塑壳不可填充式复合电极,是PH计测量元件,用来测量水溶液中的氢离子活度,即PH值。为取得更正确的结果,环境温度最好在25℃左右,已知PH值要可靠,而且其PH值愈接近被测值愈好。 pH电极每测一种pH不同的溶液,都需要使用清水清洗,建议使用去离子水清洗。

2、代码+源文件

代码
/*!
 * MindPlus
 * mpython
 *
 */
#include <MPython.h>
#include <DFRobot_Task.h>
#include <DFRobot_NeoPixel.h>

// 动态变量
volatile float mind_n_ph, mind_n_x;
// 函数声明
void DF_dengdai();
newTask(loop1)
newTask(loop2)
// 静态常量
const uint8_t imageMatrix[][350] = {
	{0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0x9f,0xff,0xff,0xff,0x9f,0xc0,0xfe,0x0,0x0,0x0,0x0,0x7,0xc0,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0xe0,0x0,0x7e,0x3f,0xc0,0xff,0xc7,0xc0,0x0,0x3e,0x3f,0xc0,0xff,0xc7,0x80,0x0,0x1e,0x1f,0xc0,0xff,0x87,0x0,0x0,0xe,0x1f,0xc0,0xff,0x8f,0x0,0x0,0xf,0x1f,0xc0,0xff,0x8f,0xff,0xff,0xff,0x1f,0xc0,0xff,0x0,0x0,0x0,0x0,0xf,0xc0,0xfe,0x0,0x0,0x0,0x0,0x7,0xc0,0xfe,0x0,0x0,0x0,0x0,0x7,0xc0,0xfe,0x0,0x0,0x0,0x0,0x7,0xc0,0xff,0x0,0x0,0x0,0x0,0xf,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0}
};
// 创建对象
DFRobot_NeoPixel neoPixel_P16;


// 主程序开始
void setup() {
	mPython.begin();
	mind_n_x = 0;
	mind_n_ph = 0.12;
	display.setCursorLine(2);
	display.printLine("【Mind+】神奇的液体");
}
void loop() {
	if ((buttonA.isPressed())) {
		taskStart(loop1);
		taskFree(loop2);
	}
	delay(500);
	if ((buttonB.isPressed())) {
		taskStart(loop2);
		taskFree(loop1);
	}
	delay(500);
}


// 子线程1程序开始
void loop1::setup() {
	neoPixel_P16.begin(P16, 12);
	neoPixel_P16.setBrightness(200);
	buzz.play(POWER_UP, Once);
	neoPixel_P16.clear();
	DF_dengdai();
}
void loop1::loop() {

}
// 子线程2程序开始
void loop2::setup() {
	neoPixel_P16.begin(P16, 12);
	neoPixel_P16.setBrightness(200);
	mind_n_x = ((((analogRead(P0))/(1024*(5.0*3.5)))+mind_n_ph)*100);
	display.fillScreen(0);
	buzz.play(POWER_DOWN, Once);
	display.setCursorLine(2);
	display.printLine("【Mind+】神奇的液体");
	display.setCursorLine(4);
	display.printLine((String("HP值:") + String((map(mind_n_x, 17, 24, 4, 9)))));
	if (((mind_n_x<=0.24) && (mind_n_x>=0.18))) {
		neoPixel_P16.setRangeColor(0, (map(mind_n_x, 12, 30, 0, 12)), 0x0000FF);
	}
	if ((mind_n_x<=0.18)) {
		neoPixel_P16.setRangeColor(0, (map(mind_n_x, 12, 30, 0, 12)), 0x0000FF);
	}
	if ((mind_n_x>=0.25)) {
		neoPixel_P16.setRangeColor(0, (map(mind_n_x, 12, 30, 0, 12)), 0x0000FF);
	}
}
void loop2::loop() {

}

// 自定义函数
void DF_dengdai() {
	for (int index = 0; index < 10; index++) {
		display.fillScreen(1);
		display.drawImage(39, 7, 50, 50, imageMatrix[0]);
		delay(100);
		display.drawImage(39, 7, 50, 50, imageMatrix[1]);
		delay(100);
		display.drawImage(39, 7, 50, 50, imageMatrix[2]);
		delay(100);
		yield();
	}
}

评论

user-avatar