所有分类
主题 主题
平台 平台
我的工作台
userHead
注册时间 [[userInfo.create_time]]
创造力 [[userInfo.creativity]]
[[userInfo.remark]]
[[d.project_title]]
articleThumb
[[d.material_name]]
timelineThumb
进入工作台
折叠
所有分类 我的工作台
展开

#智造#[infinte imagination]基于物体识别的智能物联网秤

隽隽 隽隽 2021-12-12 16:58:47

 

基于物体识别的智能物联网秤

 

佛山市石门高级中学  梁隽  刘昭玮  陈思羽

Infinite imagination 小组

      党的十九大报告中指出,我国社会的主要矛盾己经转化为不平衡不充分发展之间的矛盾。伴随着新冠疫情的爆发,人们的购物需求与疫情防控要求之间的矛盾愈加强烈。通过我们对生活中的观察发现,人们在购买水果的过程中需要经历繁琐的步骤才能将水果买到手中,那么我们怎样才能提高购买水果的效率,提升购买水果的体验, 让顾客在购买水果的时候避免不必要的接触呢?

 

步骤1 步骤1
硬件准备
材料清单 材料清单
2x
Arduino UNO主控板
1x
Leonardo 主控板
2x
二哈识别模块
1x
OLED显示屏
1x
重量传感器
1x
电机
1x
电机驱动板
1x
7.4V电池
2x
WS2812灯带
1x
WS2812灯板
1x
语音识别模块
1x
ESP-32模块
1x
扬声器
步骤2 步骤2
明确作品功能及方向

 

1.基于物体识别,可以自动检测水果的类型

2.可以自动秤出水果质量并计算价格

3.有物联网功能,可以基于手机控制

 

步骤3 步骤3
编辑程序

     基于mind+,识别部分分别用两块UNO板控制,一块负责处理人脸数据和灯效,一块负责处理水果数据和重量,最后发送给ESP-32模块上传到云端,而Leonardo负责控制转换电池与电源适配器的切换工作,并显示电池剩余电量和当前供电状态

 

人脸识别模块

负责接收人脸模块的数据和控制灯带并于称重模块进行通讯

代码 代码
	                    					/*!
 * MindPlus
 * uno
 *
 */
//V5.0 by Infinite imagination
#include <SoftwareSerial.h>
#include <DFRobot_NeoPixel.h>
#include <DFRobot_HuskyLens.h>

// 动态变量
volatile float mind_n_R2, mind_n_G2, mind_n_B2, mind_n_DaGouLiangDu, mind_n_G, mind_n_R,
               mind_n_B, mind_n_YuanQuanYanChi, mind_n_DaQuanDengDaiHuaQuanYanChi,
               mind_n_G2MAX, mind_n_DaQuanDengDaiDengZhuZongShu, mind_n_DaQuanGMax,
               mind_n_BiaoQingLiangDu, mind_n_Rlogo, mind_n_Blogo, mind_n_logo_CaiSe,
               mind_n_DongTaiBiaoQingR, mind_n_DongTaiBiaoQingG, mind_n_DongTaiBiaoQingB,
               mind_n_DaQuanShuZhi, mind_n_DaQuanDengZhu, mind_n_DaQuanGHuXi, mind_n_DaGouYanShiHou,
               mind_n_DaGouYanShi;
// 函数声明
void     DF_BianLiangSheZhi();
void     DF_DongTaiBiaoQing();
uint32_t rgbToColor(uint8_t r, uint8_t g, uint8_t b);
void     DF_logo();
void     DF_logo_caise();
void     DF_YuanQuanJingTai();
void     DF_DongTaiBiaoQingZiDong();
void     DF_YuanQuanAn();
void     DF_infinite_logo_DongHua();
void     DF_YanShenKongDong();
void     DF_DongTaiYuanQuan();
void     DF_DaQuanDengDaiDongXiao();
void     DF_DaQuanBaiSe();
void     DF_YuanQuanLiang();
void     DF_DaQuanAn();
void     DF_DaQuanLiang();
void     DF_DaGou();
void     DF_MianWuBiaoQing();
void     DF_XiaoKouChangKai();
void     DF_DaQuanXianShi();
// 创建对象
DFRobot_NeoPixel  neoPixel_8;
DFRobot_NeoPixel  neoPixel_7;
DFRobot_HuskyLens huskylens;
SoftwareSerial    softwareSerial1(2, 9);


// 主程序开始
void setup() {
	softwareSerial1.begin(9600);
	DF_BianLiangSheZhi();
	neoPixel_8.begin(8, 63);
	neoPixel_7.begin(7, mind_n_DaQuanDengDaiDengZhuZongShu);
	huskylens.beginSoftwareSerialUntilSuccess(3, 5);
	huskylens.writeAlgorithm(ALGORITHM_FACE_RECOGNITION);
	huskylens.clearOSD();
	huskylens.writeOSD(String("     Infinite    "), 1, 1);
	huskylens.writeOSD(String("imagination"), 1, 31);
	DF_infinite_logo_DongHua();
	digitalWrite(12, LOW);
	while (!(analogRead(A5)==1023)) {
		digitalWrite(4, LOW);
		analogWrite(6, 50);
	}
	digitalWrite(4, HIGH);
	analogWrite(6, 55);
	delay(6000);
	analogWrite(6, 0);
	softwareSerial1.println("@PlayTF#0002$");
	DF_DaGou();
}
void loop() {
	huskylens.request();
	if (huskylens.isAppearDirect(HUSKYLENSResultBlock)) {
		digitalWrite(12, HIGH);
		DF_DongTaiYuanQuan();
		DF_DaQuanXianShi();
		for (int index = 0; index < 4; index++) {
			if ((mind_n_DaQuanShuZhi==0)) {
				DF_YuanQuanAn();
			}
			DF_DaQuanXianShi();
			if ((mind_n_DaQuanShuZhi==0)) {
				DF_YuanQuanLiang();
			}
			DF_DaQuanXianShi();
		}
		DF_DaQuanXianShi();
		if ((mind_n_DaQuanShuZhi==0)) {
			DF_YuanQuanAn();
		}
		digitalWrite(12, LOW);
		DF_DaQuanXianShi();
	}
	DF_XiaoKouChangKai();
	delay(500);
	DF_MianWuBiaoQing();
	delay(1000);
	mind_n_DaQuanShuZhi = 0;
	neoPixel_7.clear();
}


// 自定义函数
void DF_BianLiangSheZhi() {
	mind_n_R2 = 0;
	mind_n_G2 = 0;
	mind_n_B2 = 0;
	mind_n_DaGouLiangDu = 20;
	mind_n_G = 10;
	mind_n_R = 0;
	mind_n_B = 0;
	mind_n_YuanQuanYanChi = 0.1;
	mind_n_DaQuanDengDaiHuaQuanYanChi = 0.05;
	mind_n_G2MAX = 50;
	mind_n_DaQuanDengDaiDengZhuZongShu = 50;
	mind_n_DaQuanGMax = 50;
	mind_n_BiaoQingLiangDu = 10;
	mind_n_Rlogo = 10;
	mind_n_G = 10;
	mind_n_Blogo = 10;
	mind_n_logo_CaiSe = 1;
	mind_n_DongTaiBiaoQingR = 10;
	mind_n_DongTaiBiaoQingG = 10;
	mind_n_DongTaiBiaoQingB = 10;
}
void DF_DongTaiBiaoQing() {
	neoPixel_8.setRangeColor(11, 12, rgbToColor(round(mind_n_DongTaiBiaoQingR), round(mind_n_DongTaiBiaoQingG), round(mind_n_DongTaiBiaoQingB)));
	neoPixel_8.setRangeColor(18, 18, rgbToColor(round(mind_n_DongTaiBiaoQingR), round(mind_n_DongTaiBiaoQingG), round(mind_n_DongTaiBiaoQingB)));
	neoPixel_8.setRangeColor(21, 21, rgbToColor(round(mind_n_DongTaiBiaoQingR), round(mind_n_DongTaiBiaoQingG), round(mind_n_DongTaiBiaoQingB)));
	neoPixel_8.setRangeColor(40, 42, rgbToColor(round(mind_n_DongTaiBiaoQingR), round(mind_n_DongTaiBiaoQingG), round(mind_n_DongTaiBiaoQingB)));
	neoPixel_8.setRangeColor(45, 47, rgbToColor(round(mind_n_DongTaiBiaoQingR), round(mind_n_DongTaiBiaoQingG), round(mind_n_DongTaiBiaoQingB)));
}
void DF_logo() {
	neoPixel_8.setRangeColor(11, 11, rgbToColor(round(mind_n_Rlogo), round(mind_n_G), round(mind_n_Blogo)));
	neoPixel_8.setRangeColor(20, 20, rgbToColor(round(mind_n_Rlogo), round(mind_n_G), round(mind_n_Blogo)));
	neoPixel_8.setRangeColor(27, 27, rgbToColor(round(mind_n_Rlogo), round(mind_n_G), round(mind_n_Blogo)));
	neoPixel_8.setRangeColor(36, 39, rgbToColor(round(mind_n_Rlogo), round(mind_n_G), round(mind_n_Blogo)));
	neoPixel_8.setRangeColor(43, 43, rgbToColor(round(mind_n_Rlogo), round(mind_n_G), round(mind_n_Blogo)));
	neoPixel_8.setRangeColor(52, 52, rgbToColor(round(mind_n_Rlogo), round(mind_n_G), round(mind_n_Blogo)));
	neoPixel_8.setRangeColor(56, 56, rgbToColor(round(mind_n_Rlogo), round(mind_n_G), round(mind_n_Blogo)));
	neoPixel_8.setRangeColor(57, 62, rgbToColor(round(mind_n_Rlogo), round(mind_n_G), round(mind_n_Blogo)));
}
void DF_logo_caise() {
	neoPixel_8.setRangeColor(11, 11, rgbToColor(round((mind_n_logo_CaiSe * 2)), round((mind_n_logo_CaiSe * 12)), round((mind_n_logo_CaiSe * 21))));
	neoPixel_8.setRangeColor(20, 20, rgbToColor(round((mind_n_logo_CaiSe * 3)), round((mind_n_logo_CaiSe * 11)), round((mind_n_logo_CaiSe * 21))));
	neoPixel_8.setRangeColor(27, 27, rgbToColor(round((mind_n_logo_CaiSe * 3)), round((mind_n_logo_CaiSe * 8)), round((mind_n_logo_CaiSe * 21))));
	neoPixel_8.setRangeColor(36, 36, rgbToColor(round((mind_n_logo_CaiSe * 5)), round((mind_n_logo_CaiSe * 7)), round((mind_n_logo_CaiSe * 22))));
	neoPixel_8.setRangeColor(43, 43, rgbToColor(round((mind_n_logo_CaiSe * 5)), round((mind_n_logo_CaiSe * 6)), round((mind_n_logo_CaiSe * 22))));
	neoPixel_8.setRangeColor(52, 52, rgbToColor(round((mind_n_logo_CaiSe * 6)), round((mind_n_logo_CaiSe * 5)), round((mind_n_logo_CaiSe * 22))));
	neoPixel_8.setRangeColor(37, 37, rgbToColor(round((mind_n_logo_CaiSe * 7)), round((mind_n_logo_CaiSe * 7)), round((mind_n_logo_CaiSe * 21))));
	neoPixel_8.setRangeColor(38, 38, rgbToColor(round((mind_n_logo_CaiSe * 9)), round((mind_n_logo_CaiSe * 5)), round((mind_n_logo_CaiSe * 17))));
	neoPixel_8.setRangeColor(39, 39, rgbToColor(round((mind_n_logo_CaiSe * 12)), round((mind_n_logo_CaiSe * 2)), round((mind_n_logo_CaiSe * 15))));
	neoPixel_8.setRangeColor(56, 56, rgbToColor(round((mind_n_logo_CaiSe * 15)), round((mind_n_logo_CaiSe * 2)), round((mind_n_logo_CaiSe * 22))));
	neoPixel_8.setRangeColor(57, 57, rgbToColor(round((mind_n_logo_CaiSe * 12)), round((mind_n_logo_CaiSe * 3)), round((mind_n_logo_CaiSe * 23))));
	neoPixel_8.setRangeColor(58, 58, rgbToColor(round((mind_n_logo_CaiSe * 9)), round((mind_n_logo_CaiSe * 4)), round((mind_n_logo_CaiSe * 22))));
	neoPixel_8.setRangeColor(59, 59, rgbToColor(round((mind_n_logo_CaiSe * 7)), round((mind_n_logo_CaiSe * 4)), round((mind_n_logo_CaiSe * 22))));
	neoPixel_8.setRangeColor(60, 60, rgbToColor(round((mind_n_logo_CaiSe * 5)), round((mind_n_logo_CaiSe * 5)), round((mind_n_logo_CaiSe * 22))));
	neoPixel_8.setRangeColor(61, 61, rgbToColor(round((mind_n_logo_CaiSe * 4)), round((mind_n_logo_CaiSe * 5)), round((mind_n_logo_CaiSe * 22))));
	neoPixel_8.setRangeColor(62, 62, rgbToColor(round((mind_n_logo_CaiSe * 2)), round((mind_n_logo_CaiSe * 6)), round((mind_n_logo_CaiSe * 20))));
}
void DF_YuanQuanJingTai() {
	neoPixel_8.setRangeColor(3, 3, rgbToColor(round(mind_n_R2), round(mind_n_G2), round(mind_n_B2)));
	neoPixel_8.setRangeColor(3, 4, rgbToColor(round(mind_n_R2), round(mind_n_G2), round(mind_n_B2)));
	neoPixel_8.setRangeColor(9, 9, rgbToColor(round(mind_n_R2), round(mind_n_G2), round(mind_n_B2)));
	neoPixel_8.setRangeColor(24, 24, rgbToColor(round(mind_n_R2), round(mind_n_G2), round(mind_n_B2)));
	neoPixel_8.setRangeColor(39, 39, rgbToColor(round(mind_n_R2), round(mind_n_G2), round(mind_n_B2)));
	neoPixel_8.setRangeColor(54, 54, rgbToColor(round(mind_n_R2), round(mind_n_G2), round(mind_n_B2)));
	neoPixel_8.setRangeColor(59, 59, rgbToColor(round(mind_n_R2), round(mind_n_G2), round(mind_n_B2)));
	neoPixel_8.setRangeColor(14, 14, rgbToColor(round(mind_n_R2), round(mind_n_G2), round(mind_n_B2)));
	neoPixel_8.setRangeColor(31, 31, rgbToColor(round(mind_n_R2), round(mind_n_G2), round(mind_n_B2)));
	neoPixel_8.setRangeColor(32, 32, rgbToColor(round(mind_n_R2), round(mind_n_G2), round(mind_n_B2)));
	neoPixel_8.setRangeColor(49, 49, rgbToColor(round(mind_n_R2), round(mind_n_G2), round(mind_n_B2)));
	neoPixel_8.setRangeColor(60, 60, rgbToColor(round(mind_n_R2), round(mind_n_G2), round(mind_n_B2)));
}
void DF_DongTaiBiaoQingZiDong() {
	if ((huskylens.readBlockCenterParameterDirect().xCenter<=120)) {
		neoPixel_8.setRangeColor(39, 39, rgbToColor(round(mind_n_DongTaiBiaoQingR), round(mind_n_DongTaiBiaoQingG), round(mind_n_DongTaiBiaoQingB)));
		neoPixel_8.setRangeColor(34, 34, rgbToColor(round(mind_n_DongTaiBiaoQingR), round(mind_n_DongTaiBiaoQingG), round(mind_n_DongTaiBiaoQingB)));
		neoPixel_8.setRangeColor(33, 33, 0x000000);
		neoPixel_8.setRangeColor(32, 32, 0x000000);
		neoPixel_8.setRangeColor(38, 38, 0x000000);
		neoPixel_8.setRangeColor(37, 37, 0x000000);
	}
	if (((huskylens.readBlockCenterParameterDirect().xCenter>=121) && (huskylens.readBlockCenterParameterDirect().xCenter<=179))) {
		neoPixel_8.setRangeColor(39, 39, 0x000000);
		neoPixel_8.setRangeColor(34, 34, 0x000000);
		neoPixel_8.setRangeColor(33, 33, rgbToColor(round(mind_n_DongTaiBiaoQingR), round(mind_n_DongTaiBiaoQingG), round(mind_n_DongTaiBiaoQingB)));
		neoPixel_8.setRangeColor(32, 32, 0x000000);
		neoPixel_8.setRangeColor(38, 38, rgbToColor(round(mind_n_DongTaiBiaoQingR), round(mind_n_DongTaiBiaoQingG), round(mind_n_DongTaiBiaoQingB)));
		neoPixel_8.setRangeColor(37, 37, 0x000000);
	}
	if ((huskylens.readBlockCenterParameterDirect().xCenter>=180)) {
		neoPixel_8.setRangeColor(39, 39, 0x000000);
		neoPixel_8.setRangeColor(34, 34, 0x000000);
		neoPixel_8.setRangeColor(33, 33, 0x000000);
		neoPixel_8.setRangeColor(32, 32, rgbToColor(round(mind_n_DongTaiBiaoQingR), round(mind_n_DongTaiBiaoQingG), round(mind_n_DongTaiBiaoQingB)));
		neoPixel_8.setRangeColor(38, 38, 0x000000);
		neoPixel_8.setRangeColor(37, 37, rgbToColor(round(mind_n_DongTaiBiaoQingR), round(mind_n_DongTaiBiaoQingG), round(mind_n_DongTaiBiaoQingB)));
	}
	delay(200);
}
void DF_YuanQuanAn() {
	mind_n_G2 = mind_n_G2MAX;
	while (!(mind_n_G2<=0)) {
		DF_YuanQuanJingTai();
		mind_n_G2 = (mind_n_G2 - 1);
		delay(0.001);
	}
}
void DF_infinite_logo_DongHua() {
	DF_logo();
	delay(500);
	neoPixel_8.setRangeColor(50, 50, 0x000000);
	neoPixel_8.setRangeColor(50, 50, rgbToColor(round(mind_n_Rlogo), round(mind_n_G), round(mind_n_Blogo)));
	delay(200);
	neoPixel_8.setRangeColor(45, 45, rgbToColor(round(mind_n_Rlogo), round(mind_n_G), round(mind_n_Blogo)));
	neoPixel_8.setRangeColor(50, 50, 0x000000);
	delay(200);
	neoPixel_8.setRangeColor(45, 45, 0x000000);
	neoPixel_8.setRangeColor(34, 34, rgbToColor(round(mind_n_Rlogo), round(mind_n_G), round(mind_n_Blogo)));
	delay(200);
	neoPixel_8.setRangeColor(34, 34, 0x000000);
	DF_logo_caise();
	neoPixel_8.setRangeColor(29, 29, rgbToColor(round(10), round(8), round(24)));
	delay(200);
	neoPixel_8.setRangeColor(29, 29, 0x000000);
	neoPixel_8.setRangeColor(34, 34, rgbToColor(round(10), round(8), round(24)));
	delay(300);
}
void DF_YanShenKongDong() {
	neoPixel_8.setBrightness(mind_n_BiaoQingLiangDu);
	neoPixel_8.clear();
	neoPixel_8.setRangeColor(32, 34, 0xFFFFFF);
	neoPixel_8.setRangeColor(37, 39, 0xFFFFFF);
	neoPixel_8.setRangeColor(19, 20, 0xFFFFFF);
	neoPixel_8.setRangeColor(32, 32, 0xFFFFFF);
	neoPixel_8.setRangeColor(34, 34, 0xFFFFFF);
	neoPixel_8.setRangeColor(37, 37, 0xFFFFFF);
	neoPixel_8.setRangeColor(39, 39, 0xFFFFFF);
	neoPixel_8.setRangeColor(40, 40, 0xFFFFFF);
	neoPixel_8.setRangeColor(42, 42, 0xFFFFFF);
	neoPixel_8.setRangeColor(45, 45, 0xFFFFFF);
	neoPixel_8.setRangeColor(47, 47, 0xFFFFFF);
	neoPixel_8.setRangeColor(48, 50, 0xFFFFFF);
	neoPixel_8.setRangeColor(53, 55, 0xFFFFFF);
}
void DF_DongTaiYuanQuan() {
	neoPixel_8.clear();
	mind_n_G = mind_n_G2MAX;
	neoPixel_8.setBrightness(50);
	neoPixel_8.setRangeColor(3, 3, rgbToColor(round(mind_n_R), round(mind_n_G), round(mind_n_B)));
	delay(mind_n_YuanQuanYanChi * 1000);
	neoPixel_8.setRangeColor(3, 4, rgbToColor(round(mind_n_R), round(mind_n_G), round(mind_n_B)));
	delay(mind_n_YuanQuanYanChi * 1000);
	neoPixel_8.setRangeColor(9, 9, rgbToColor(round(mind_n_R), round(mind_n_G), round(mind_n_B)));
	delay(mind_n_YuanQuanYanChi * 1000);
	neoPixel_8.setRangeColor(24, 24, rgbToColor(round(mind_n_R), round(mind_n_G), round(mind_n_B)));
	delay(mind_n_YuanQuanYanChi * 1000);
	neoPixel_8.setRangeColor(39, 39, rgbToColor(round(mind_n_R), round(mind_n_G), round(mind_n_B)));
	delay(mind_n_YuanQuanYanChi * 1000);
	neoPixel_8.setRangeColor(54, 54, rgbToColor(round(mind_n_R), round(mind_n_G), round(mind_n_B)));
	delay(mind_n_YuanQuanYanChi * 1000);
	neoPixel_8.setRangeColor(59, 59, rgbToColor(round(mind_n_R), round(mind_n_G), round(mind_n_B)));
	delay(mind_n_YuanQuanYanChi * 1000);
	neoPixel_8.setRangeColor(60, 60, rgbToColor(round(mind_n_R), round(mind_n_G), round(mind_n_B)));
	delay(mind_n_YuanQuanYanChi * 1000);
	neoPixel_8.setRangeColor(49, 49, rgbToColor(round(mind_n_R), round(mind_n_G), round(mind_n_B)));
	delay(mind_n_YuanQuanYanChi * 1000);
	neoPixel_8.setRangeColor(32, 32, rgbToColor(round(mind_n_R), round(mind_n_G), round(mind_n_B)));
	delay(mind_n_YuanQuanYanChi * 1000);
	neoPixel_8.setRangeColor(31, 31, rgbToColor(round(mind_n_R), round(mind_n_G), round(mind_n_B)));
	delay(mind_n_YuanQuanYanChi * 1000);
	neoPixel_8.setRangeColor(14, 14, rgbToColor(round(mind_n_R), round(mind_n_G), round(mind_n_B)));
}
void DF_DaQuanDengDaiDongXiao() {
	mind_n_DaQuanDengZhu = 0;
	for (int index = 0; index < (mind_n_DaQuanDengDaiDengZhuZongShu - 1); index++) {
		neoPixel_7.setRangeColor(0, mind_n_DaQuanDengZhu, rgbToColor(round(0), round(mind_n_G2MAX), round(0)));
		mind_n_DaQuanDengZhu = (mind_n_DaQuanDengZhu + 1);
		delay(mind_n_DaQuanDengDaiHuaQuanYanChi * 1000);
	}
	mind_n_DaQuanDengZhu = 0;
}
void DF_DaQuanBaiSe() {
	mind_n_DaQuanDengZhu = 0;
	for (int index = 0; index < (mind_n_DaQuanDengDaiDengZhuZongShu - 1); index++) {
		neoPixel_7.setRangeColor(0, mind_n_DaQuanDengZhu, rgbToColor(round(10), round(10), round(10)));
		mind_n_DaQuanDengZhu = (mind_n_DaQuanDengZhu + 1);
		delay(mind_n_DaQuanDengDaiHuaQuanYanChi * 1000);
	}
	mind_n_DaQuanDengZhu = 0;
}
void DF_YuanQuanLiang() {
	mind_n_G2 = 0;
	while (!(mind_n_G2>=mind_n_G2MAX)) {
		DF_YuanQuanJingTai();
		mind_n_G2 = (mind_n_G2 + 1);
		delay(0.001);
	}
}
void DF_DaQuanAn() {
	mind_n_DaQuanGHuXi = mind_n_DaQuanGMax;
	while (!(mind_n_DaQuanGHuXi<=0)) {
		neoPixel_7.setRangeColor(0, mind_n_DaQuanDengDaiDengZhuZongShu, rgbToColor(round(0), round(mind_n_DaQuanGHuXi), round(0)));
		mind_n_DaQuanGHuXi = (mind_n_DaQuanGHuXi - 1);
		delay(5);
	}
}
void DF_DaQuanLiang() {
	mind_n_DaQuanGHuXi = 0;
	while (!(mind_n_DaQuanGHuXi>=mind_n_DaQuanGMax)) {
		neoPixel_7.setRangeColor(0, mind_n_DaQuanDengDaiDengZhuZongShu, rgbToColor(round(0), round(mind_n_DaQuanGHuXi), round(0)));
		mind_n_DaQuanGHuXi = (mind_n_DaQuanGHuXi + 1);
		delay(5);
	}
}
void DF_DaGou() {
	mind_n_DaGouYanShiHou = 0.05;
	mind_n_DaGouYanShi = 0.1;
	neoPixel_8.clear();
	neoPixel_8.setBrightness(mind_n_DaGouLiangDu);
	neoPixel_8.setRangeColor(30, 30, 0x00FF00);
	delay(mind_n_DaGouYanShi * 1000);
	neoPixel_8.setRangeColor(18, 18, 0x00FF00);
	delay(mind_n_DaGouYanShi * 1000);
	neoPixel_8.setRangeColor(12, 12, 0x00FF00);
	delay(mind_n_DaGouYanShi * 1000);
	neoPixel_8.setRangeColor(20, 20, 0x00FF00);
	delay(mind_n_DaGouYanShi * 1000);
	neoPixel_8.setRangeColor(26, 26, 0x00FF00);
	delay(mind_n_DaGouYanShiHou * 1000);
	neoPixel_8.setRangeColor(38, 38, 0x00FF00);
	delay(mind_n_DaGouYanShiHou * 1000);
	neoPixel_8.setRangeColor(40, 40, 0x00FF00);
	delay(1000);
}
void DF_MianWuBiaoQing() {
	neoPixel_8.clear();
	neoPixel_8.setBrightness(mind_n_BiaoQingLiangDu);
	neoPixel_8.setRangeColor(19, 20, 0xFFFFFF);
	neoPixel_8.setRangeColor(32, 34, 0xFFFFFF);
	neoPixel_8.setRangeColor(37, 39, 0xFFFFFF);
}
void DF_XiaoKouChangKai() {
	neoPixel_8.setBrightness(mind_n_BiaoQingLiangDu);
	neoPixel_8.clear();
	neoPixel_8.setRangeColor(19, 20, 0xFFFFFF);
	neoPixel_8.setRangeColor(32, 32, 0xFFFFFF);
	neoPixel_8.setRangeColor(34, 34, 0xFFFFFF);
	neoPixel_8.setRangeColor(37, 37, 0xFFFFFF);
	neoPixel_8.setRangeColor(39, 39, 0xFFFFFF);
	neoPixel_8.setRangeColor(40, 40, 0xFFFFFF);
	neoPixel_8.setRangeColor(42, 42, 0xFFFFFF);
	neoPixel_8.setRangeColor(45, 45, 0xFFFFFF);
	neoPixel_8.setRangeColor(47, 47, 0xFFFFFF);
	neoPixel_8.setRangeColor(48, 50, 0xFFFFFF);
	neoPixel_8.setRangeColor(53, 55, 0xFFFFFF);
}
void DF_DaQuanXianShi() {
	if ((analogRead(A1)>700)) {
		mind_n_DaQuanShuZhi = 1;
		if ((mind_n_DaQuanShuZhi==1)) {
			neoPixel_8.clear();
			DF_DaQuanDengDaiDongXiao();
			neoPixel_8.clear();
			while (!(analogRead(A1)<=700)) {
				DF_DaQuanAn();
				DF_DaQuanLiang();
			}
			DF_DaQuanAn();
			neoPixel_7.clear();
			softwareSerial1.println("@PlayTF#0006$");
			DF_DaGou();
		}
	}
}

// 静态函数
uint32_t rgbToColor(uint8_t r, uint8_t g, uint8_t b)
{
  return (uint32_t)((((uint32_t)r<<16) | ((uint32_t)g<<8)) | (uint32_t)b);
}

	                    				

物体识别模块

接收物体识别的水果数据和秤的重量数据,与人脸识别模块和ESP-32进行通讯

代码 代码
	                    					/*!
 * MindPlus
 * uno
 *
 */
//V4.7 by Infinite imagination
#include <ThreeWire.h>
#include <RtcDS1302.h>
#include <DFRobot_Hx711.h>
#include <DFRobot_eeprom.h>
#include <DFRobot_HuskyLens.h>
#include <DFRobot_SSD1306_I2C.h>

// 动态变量
String         mind_s_PinZhong;
volatile float mind_n_DanJia, mind_n_PingGuoDanJia, mind_n_JuZiDanJia, mind_n_LiDanJia,
               mind_n_GuKe, mind_n_ZhiLiang, mind_n_ZongJia;
// 函数声明
void DF_DanJiaSheZhi();
void DF_JiaZaiHouBanBuFen();
void DF_JiaZaiQianBanBuFen();
void DF_ChenZhong();
// 创建对象
DFRobot_SSD1306_I2C  oled12864;
DFRobot_HuskyLens    huskylens;
ThreeWire            myWire(3,4,2);
RtcDS1302<ThreeWire> Rtc(myWire);
Hx711                scaleA2A3;
DFRobot_Eeprom       eeprom;


// 主程序开始
void setup() {
	Serial.begin(9600);
	Rtc.Begin();
	scaleA2A3.begin(A2,A3);
	oled12864.begin(0x3c);
	oled12864.setCursorLine(2);
	oled12864.printLine("    Infinite");
	oled12864.setCursorLine(3);
	oled12864.printLine("  imagination");
	huskylens.beginSoftwareSerialUntilSuccess(2, 4);
	huskylens.clearOSD();
	huskylens.writeOSD(String("     Infinite    "), 110, 100);
	huskylens.writeOSD(String("imagination"), 110, 130);
	DF_DanJiaSheZhi();
	huskylens.writeAlgorithm(ALGORITHM_OBJECT_CLASSIFICATION);
	digitalWrite(11, LOW);
	delay(3000);
	scaleA2A3.setScale(1992);
	oled12864.fillScreen(0);
	DF_JiaZaiQianBanBuFen();
	Serial.println(scaleA2A3.getGram());
	huskylens.clearOSD();
	if ((Serial.read()>=-9)) {
		digitalWrite(11, HIGH);
		Serial.println("hello");
		delay(1000);
		DF_JiaZaiHouBanBuFen();
		oled12864.fillScreen(0);
		oled12864.setCursorLine(2);
		oled12864.printLine("     Finish");
		oled12864.setCursorLine(3);
		oled12864.printLine("    *^____^*");
		delay(2000);
	}
	digitalWrite(11, LOW);
	// 月10
	// 日11
	// 当日人数30
	if (((Rtc.GetDateTime().Month())==eeprom.read(10))) {
		if (((Rtc.GetDateTime().Day())==eeprom.read(11))) {
			delay(100);
		}
		else {
			eeprom.write(10,(Rtc.GetDateTime().Month()));
			eeprom.write(11,(Rtc.GetDateTime().Day()));
			eeprom.write(50,0);
			delay(100);
		}
	}
	else {
		eeprom.write(10,(Rtc.GetDateTime().Month()));
		eeprom.write(11,(Rtc.GetDateTime().Day()));
		eeprom.write(50,0);
		delay(100);
	}
	mind_n_GuKe = eeprom.read(50);
	delay(100);
}
void loop() {
	huskylens.writeOSD(String("     Infinite    "), 1, 1);
	huskylens.writeOSD(String("imagination"), 1, 31);
	if ((analogRead(A0)<=699)) {
		oled12864.setCursorLine(2);
		oled12864.printLine("    Looking");
		oled12864.setCursorLine(3);
		oled12864.printLine("     here");
		oled12864.setCursorLine(4);
		oled12864.printLine("    (^///^)");
		delay(100);
	}
	if ((analogRead(A0)>=700)) {
		oled12864.setCursorLine(2);
		oled12864.printLine("     Face");
		oled12864.setCursorLine(3);
		oled12864.printLine("  recognition");
		oled12864.setCursorLine(4);
		oled12864.printLine("      >_<");
		delay(200);
		if ((scaleA2A3.getGram()>=10)) {
			huskylens.clearOSD();
			huskylens.request();
			if (huskylens.isAppear(1,HUSKYLENSResultBlock)) {
				huskylens.writeOSD(String("Apple"), 230, 35);
				mind_s_PinZhong = "苹果";
				oled12864.fillScreen(0);
				oled12864.setCursorLine(2);
				oled12864.printLine("    Fruit");
				oled12864.setCursorLine(3);
				oled12864.printLine("     Apple");
			}
			if (huskylens.isAppear(2,HUSKYLENSResultBlock)) {
				huskylens.writeOSD(String("Orange"), 230, 35);
				mind_s_PinZhong = "橙子";
				oled12864.fillScreen(0);
				oled12864.setCursorLine(2);
				oled12864.printLine("    Fruit");
				oled12864.setCursorLine(3);
				oled12864.printLine("     Orange");
			}
			if (huskylens.isAppear(3,HUSKYLENSResultBlock)) {
				huskylens.writeOSD(String("pear"), 230, 35);
				mind_s_PinZhong = "梨";
				oled12864.fillScreen(0);
				oled12864.setCursorLine(2);
				oled12864.printLine("   Fruit");
				oled12864.setCursorLine(3);
				oled12864.printLine("       Pear");
			}
			huskylens.clearOSD();
			digitalWrite(11, HIGH);
			delay(5000);
			DF_ChenZhong();
			mind_n_GuKe = (mind_n_GuKe + 1);
			eeprom.write(50,mind_n_GuKe);
			delay(100);
			if ((mind_s_PinZhong==String("苹果"))) {
				mind_n_ZongJia = (mind_n_ZhiLiang * mind_n_PingGuoDanJia);
				mind_n_DanJia = mind_n_PingGuoDanJia;
				oled12864.setCursorLine(1);
				oled12864.printLine("     Apple");
				huskylens.writeOSD(String("Apple"), 230, 35);
			}
			if ((mind_s_PinZhong==String("橘子"))) {
				mind_n_ZongJia = (mind_n_ZhiLiang * mind_n_JuZiDanJia);
				mind_n_DanJia = mind_n_JuZiDanJia;
				oled12864.setCursorLine(1);
				oled12864.printLine("   Orange");
				huskylens.writeOSD(String("Orange"), 230, 35);
			}
			if ((mind_s_PinZhong==String("梨"))) {
				mind_n_ZongJia = (mind_n_ZhiLiang * mind_n_LiDanJia);
				mind_n_DanJia = mind_n_LiDanJia;
				oled12864.setCursorLine(1);
				oled12864.printLine("      Pear");
				huskylens.writeOSD(String("pear"), 230, 35);
			}
			huskylens.writeOSD(String((String("No.") + String(mind_n_GuKe))), 0, 120);
			huskylens.writeOSD(String((String("Unit Price:") + String(mind_n_DanJia))), 0, 150);
			oled12864.setCursorLine(2);
			oled12864.printLine((String("Unit:") + String(mind_n_DanJia)));
			huskylens.writeOSD(String((String("Quality:") + String((String(mind_n_ZhiLiang) + String("   "))))), 0, 180);
			oled12864.setCursorLine(3);
			oled12864.printLine((String("Quality:") + String((String(mind_n_ZhiLiang) + String("   ")))));
			huskylens.writeOSD(String((String("Price:") + String((String(mind_n_ZongJia) + String("     "))))), 0, 210);
			oled12864.setCursorLine(4);
			oled12864.printLine((String("Price:") + String((String(mind_n_ZongJia) + String("     ")))));
			delay(3000);
			while (!(scaleA2A3.getGram()<=10)) {}
			delay(1000);
			digitalWrite(11, LOW);
			oled12864.fillScreen(0);
			huskylens.clearOSD();
		}
		oled12864.fillScreen(0);
	}
}


// 自定义函数
void DF_DanJiaSheZhi() {
	mind_n_DanJia = 0;
	mind_n_PingGuoDanJia = 0.018;
	mind_n_JuZiDanJia = 0.025;
	mind_n_LiDanJia = 1.9;
	mind_n_GuKe = 0;
}
void DF_JiaZaiHouBanBuFen() {
	oled12864.setCursorLine(4);
	oled12864.printLine(".(; > _ <)");
	delay(200);
	oled12864.setCursorLine(3);
	oled12864.printLine("----------");
	delay(100);
	oled12864.setCursorLine(3);
	oled12864.printLine("------------");
	delay(200);
	oled12864.setCursorLine(3);
	oled12864.printLine("--------------");
	oled12864.setCursorLine(4);
	oled12864.printLine("..(; > _ <)");
	delay(100);
	oled12864.setCursorLine(3);
	oled12864.printLine("---------------");
	oled12864.setCursorLine(4);
	oled12864.printLine(" ...(; > _ <)");
	delay(300);
	oled12864.setCursorLine(3);
	oled12864.printLine("------------------");
	oled12864.setCursorLine(4);
	oled12864.printLine(" .....(; > _ <)");
	delay(200);
}
void DF_JiaZaiQianBanBuFen() {
	delay(100);
	oled12864.fillScreen(0);
	oled12864.setCursorLine(2);
	oled12864.printLine("   Loading...");
	oled12864.setCursorLine(3);
	oled12864.printLine("-");
	oled12864.setCursorLine(4);
	oled12864.printLine(".(; > _ <)");
	delay(100);
	oled12864.setCursorLine(3);
	oled12864.printLine("--");
	delay(100);
	oled12864.setCursorLine(3);
	oled12864.printLine("---");
	oled12864.setCursorLine(4);
	oled12864.printLine("..(; > _ <)");
	delay(100);
	oled12864.setCursorLine(3);
	oled12864.printLine("----");
	delay(200);
	oled12864.setCursorLine(3);
	oled12864.printLine("-----");
	delay(100);
	oled12864.setCursorLine(4);
	oled12864.printLine(" ...(; > _ <)");
	oled12864.setCursorLine(3);
	oled12864.printLine("------");
	delay(100);
	oled12864.setCursorLine(3);
	oled12864.printLine("-------");
	oled12864.setCursorLine(4);
	oled12864.printLine(" .....(; > _ <)");
	oled12864.fillScreen(0);
	oled12864.setCursorLine(2);
	oled12864.printLine("   Loading...");
	oled12864.setCursorLine(3);
	oled12864.printLine("--------");
	oled12864.setCursorLine(4);
	oled12864.printLine(".(; > _ <)");
}
void DF_ChenZhong() {
	mind_n_ZhiLiang = (scaleA2A3.getGram() * 4);
}


	                    				

电源控制模块

智能秤耗电功率较高,考虑电池供电只能提供临时使用的便捷, 为此设计了独立分配式电源管理模 块,可以自动切换12V外部输入与 12V电池供电。

代码 代码
	                    					//V1.8 by Infinite imagination
// A0接电池的电压
	// A1检测电源的电压
	// A2 接开关
	// D10接电池继电器
	// D11接电源继电器
	max7219.begin(9, 3, 2);
}
void loop() {
	if ((analogRead(A2)>=1000)) {
		DF_DianChiDianLiangXianShi();
		DF_DianYuanDianLiangXianShi();
	}
	else {
		digitalWrite(10, LOW);
		digitalWrite(11, LOW);
		if ((mind_n_GuanShuZhi==1)) {
			max7219.show(maxBitmap[9]);
		}
		if ((mind_n_GuanShuZhi==2)) {
			max7219.show(maxBitmap[10]);
		}
		if ((mind_n_GuanShuZhi==3)) {
			max7219.show(maxBitmap[11]);
		}
		if ((mind_n_GuanShuZhi==4)) {
			max7219.show(maxBitmap[11]);
		}
		if ((mind_n_GuanShuZhi==5)) {
			max7219.show(maxBitmap[10]);
		}
		if ((mind_n_GuanShuZhi==6)) {
			max7219.show(maxBitmap[9]);
		}
		mind_n_GuanShuZhi = (mind_n_GuanShuZhi + 1);
		if ((mind_n_GuanShuZhi>=6)) {
			mind_n_GuanShuZhi = 1;
		}
	}
	delay(200);
}


// 自定义函数
void DF_DianChiDianLiangXianShi() {
	if (((analogVoltage.getVoltage(A0)>=5) && (analogVoltage.getVoltage(A1)<=6))) {
		digitalWrite(10, HIGH);
		delay(100);
		digitalWrite(11, LOW);
		if (((mind_n_DianLiangDongHua==0) || (mind_n_DianLiangDongHua==2))) {
			DF_Dianlogo();
		}
		if ((analogVoltage.getVoltage(A0)<=6.6)) {
			max7219.show(maxBitmap[0]);
		}
		if (((analogVoltage.getVoltage(A0)>6.6) && (analogVoltage.getVoltage(A0)<=7))) {
			max7219.show(maxBitmap[1]);
		}
		if (((analogVoltage.getVoltage(A0)>7) && (analogVoltage.getVoltage(A0)<=7.8))) {
			max7219.show(maxBitmap[2]);
		}
		if (((analogVoltage.getVoltage(A0)>7.8) && (analogVoltage.getVoltage(A0)<=8))) {
			max7219.show(maxBitmap[2]);
		}
		if ((analogVoltage.getVoltage(A0)>8)) {
			max7219.show(maxBitmap[3]);
		}
		mind_n_DianLiangDongHua = 1;
	}
}
void DF_Dianlogo() {
	max7219.show(maxBitmap[4]);
	delay(100);
	max7219.show(maxBitmap[5]);
	delay(100);
	max7219.show(maxBitmap[6]);
	delay(100);
	max7219.show(maxBitmap[7]);
	delay(1000);
}
void DF_DianYuanDianLiangXianShi() {
	if ((analogVoltage.getVoltage(A1)>=6)) {
		digitalWrite(11, HIGH);
		delay(100);
		digitalWrite(10, LOW);
		if (((mind_n_DianLiangDongHua==0) || (mind_n_DianLiangDongHua==1))) {
			DF_Dianlogo();
		}
		max7219.show(maxBitmap[8]);
		mind_n_DianLiangDongHua = 2;
	}
}

	                    				

物联网通信模块

基于 Blynk APP 进行编写,采用ESP-32模块作为主控

步骤4 步骤4
初步设计结构

预想中智能秤的正面

projectImage

预想中智能秤的内部结构

projectImage
步骤5 步骤5
作品功能及外观

物体识别系统

我们为这个智能秤添加了物体识别系统,此系统可以正确地识别水果的类型,它通过大数据处理分析的结果,导入不同种类的物体提高识别的准确度。将分析数据集成一体,组装成物体识别模块。我们 先使用标签记录水果品种,对不同种类的水果进行分类,在同种水果中进行比较,再运用AI智能识别模块输出的数据与设定的水果标签进行匹配,最后得到测量的水果的品种。此系统运用的原理主要是物体识别,数据比较,数据整理。

projectImage

信息运算系统

该系统将智能秤收集的水果重量以及利用智能物体识别系统识别 出的水果品种对应的单价进行计 算。运用公式“总价=水果品种的单价×重量”进行计算,最后将结果储存并将其可视化地输出在智能秤的屏幕上。此系统既减轻了人力计算的负担,又简化了称重打秤的环节。

人脸识别系统

运用AI智能识别模块实现自动检 测人脸,首先实时检测画面内容, 对画面内容进行分析,检测出现人 脸自动识别记录,将已识别顾客的 人脸信息进行标记,对人脸信息进行预处理后的数据存储在系统的数据库里。

projectImage

物联网技术

运用物联网开发的技术,将水果信息运算系统的运算的结果与智 能人脸识别系统已识别用户的购买 信息相结合,二者数据相结合后获 得每位顾客购买信息的数据包,然 后上传到APP服务器中方便进行后 续信息的交互。

projectImage

升降式摄像头

采用可升降式框架结构,坚固耐用,并布设两组摄像头,分别 连接物体识别系统与人脸识别系 统。可升降式摄像头可自动根据 物体位置与人体高度进行调节高 度,为了避免机组卡死或异常等特 殊情况,预设了复位程序,保障 摄像头正常工作。

projectImage

一体式的外观设计

      本产品由木质结构组成,充满设计感的圆⻆矩形。厚实的称重板,上面叠加的坚固的 亚克力透光板,便于显示输出信 息。直立式框架结构,便于搬 运,便携式使用。由物体识别系 统、人脸识别系统、数字化显示 屏、电量图形显示屏的四组屏幕相结合,信息显示简明易懂,使得操作更方便。

projectImage
步骤6 步骤6
制作过程

1. 课题调研,形成可行性报告

2. 产品的外形设计和核心算法设计

3. 搜集制作此产品所需的材料

4. 开始制作此项目实现基本功能

5. 在原有的基础上添加使用的新功能

6. 成品试用及测试

7. 成品使用问题反馈及改进迭代改进

人脸识别程序迭代

projectImage

物体识别程序迭代

projectImage

电源控制部分程序迭代

projectImage
步骤7 步骤7
介绍视频
步骤8 步骤8
后续改进方案

1.串口不稳定,后续继续改进

2.降压板在工作一段时间后发热严重会导致电压不够,后续改进

3.App功能较少,后续改进

4.UNO板的EEPROM在使用过程中会出现卡顿,后续准备将储存功能放在ESP-32上

5.摄像头升降过程中可能出现卡顿,后续将改进结构

 

步骤9 步骤9
感想

       这台充满了科技感与实用价值的智能秤以崭新的面貌呈现在我们的面前,使得我们的生活更加便捷高效。当然我们的作品仍在不断追求完美,在实现安全、实用、高效的前提下,我们尽可能地完善了其功能,在问题出现时将问题作为作品的突破点不断改进创新,力求打造更完美的智能秤。我们希望这个智能秤能解决生活中的“痛点”问题,让生活更智能便捷!

by 石门高级中学 Infinite imagination 

     梁隽  刘昭玮 陈思羽

projectImage

                                     喜欢这个项目吗? ?   喜欢就点个赞吧!

Makelog作者原创文章,未经授权禁止转载。
4
5
评论
[[c.user_name]] [[c.create_time]]
[[c.parent_comment.count]]
|
[[c.comment_content]]