回到顶部 回到顶部

自动消毒机 简单

头像 diojoker 2022.07.15 424 2
代码
/*!
 * MindPlus
 * uno
 *
 */
#include <DFRobot_URM10.h>
#include <DFRobot_LedControl.h>
#include <DFRobot_LiquidCrystal_I2C.h>

// 动态变量
volatile float mind_n_XiaoDuMiaoShu, mind_n_GuDingXiaoDuDengDaiMiaoShu, mind_n_ZhuangTai,
               mind_n_XiaoDuZanTingMiaoShu, mind_n_MiaoShuHuanCun, mind_n_ZhongFuCiShu,
               mind_n_y, mind_n_x;
// 函数声明
void DF_ChuShiHua(float mind_n_CiShu);
void DF_JiSuanMoKuai();
void DF_XiaoDuQiDongMiaoShu();
// 静态常量
const uint8_t maxBitmap[][8] = {
	{B00000001,B00000011,B00000110,B10001100,B11011000,B01110000,B00100000,B00000000},
	{B10000001,B01000010,B00100100,B00011000,B00011000,B00100100,B01000010,B10000001},
	{B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000}
};
// 创建对象
DFRobot_LiquidCrystal_I2C lcd1602;
DFRobot_LedControl        max7219;
DFRobot_URM10             urm10;


// 主程序开始
void setup() {
	DF_ChuShiHua(1);
}
void loop() {
	mind_n_XiaoDuMiaoShu = 0;
	lcd1602.clear();
	lcd1602.printLine(uint32_t(1), "消毒完毕");
	max7219.show(maxBitmap[0]);
	while (!(digitalRead(A1) || (mind_n_GuDingXiaoDuDengDaiMiaoShu==120))) {
		delay(1000);
		mind_n_GuDingXiaoDuDengDaiMiaoShu += 1;
	}
	digitalWrite(10, HIGH);
	digitalWrite(10, LOW);
	lcd1602.clear();
	lcd1602.printLine(uint32_t(1), "正在消毒中");
	max7219.show(maxBitmap[1]);
	mind_n_ZhuangTai = 1;
	digitalWrite(A0, HIGH);
	digitalWrite(A2, HIGH);
	while (!((mind_n_XiaoDuMiaoShu==5) || (mind_n_XiaoDuMiaoShu==1000))) {
		DF_JiSuanMoKuai();
	}
	if ((mind_n_XiaoDuMiaoShu==1000)) {
		digitalWrite(A0, LOW);
		digitalWrite(A2, LOW);
		lcd1602.printLine(uint32_t(1), "消毒暂时暂停");
		DF_XiaoDuQiDongMiaoShu();
		digitalWrite(A0, HIGH);
		digitalWrite(A2, HIGH);
		delay(mind_n_XiaoDuMiaoShu * 1000);
	}
	else {
		digitalWrite(10, HIGH);
		digitalWrite(10, LOW);
		digitalWrite(A0, LOW);
		digitalWrite(A2, LOW);
		mind_n_ZhuangTai = 0;
		lcd1602.clear();
		lcd1602.printLine(uint32_t(1), "消毒完毕");
		max7219.show(maxBitmap[0]);
	}
}


// 自定义函数
void DF_ChuShiHua(float mind_n_CiShu) {
	for (int index = 0; index < mind_n_CiShu; index++) {
		digitalWrite(A0, LOW);
		digitalWrite(A2, LOW);
		lcd1602.begin(9);
		max7219.begin(5, 7, 6);
		max7219.show(maxBitmap[2]);
		lcd1602.clear();
		mind_n_XiaoDuZanTingMiaoShu = 0;
		mind_n_MiaoShuHuanCun = 0;
		mind_n_XiaoDuMiaoShu = 0;
		mind_n_ZhuangTai = 0;
		mind_n_ZhongFuCiShu = 0;
		mind_n_GuDingXiaoDuDengDaiMiaoShu = 0;
	}
}
void DF_JiSuanMoKuai() {
	if ((mind_n_ZhuangTai==1)) {
		delay(1000);
		mind_n_XiaoDuMiaoShu += 1;
	}
	if (((urm10.getDistanceCM(4, 5))<=100)) {
		mind_n_XiaoDuMiaoShu = 1000;
	}
}
void DF_XiaoDuQiDongMiaoShu() {
	mind_n_MiaoShuHuanCun = mind_n_XiaoDuMiaoShu;
	mind_n_y = -10;
	mind_n_x = 0;
	mind_n_ZhongFuCiShu = 0;
	while (!(mind_n_ZhongFuCiShu==30)) {
		mind_n_ZhongFuCiShu = mind_n_XiaoDuZanTingMiaoShu;
		lcd1602.printLine(uint32_t(1), (String(mind_n_XiaoDuZanTingMiaoShu) + String("            秒后开始消毒")));
		mind_n_XiaoDuZanTingMiaoShu -= 1;
		for (int index = 0; index < 10; index++) {
			if (digitalRead(5)) {
				mind_n_ZhongFuCiShu = 30;
			}
			mind_n_x += 1;
			delay(100);
			lcd1602.print(uint32_t(mind_n_x), uint32_t(mind_n_y), "...");
		}
	}
}

 

² 作品创意灵感

我们的小区里,在做核酸时每次消毒都要花上几分钟穿好设备,再背着很重的水箱进行消毒,非常耗费体力。如果将穿设备的几分钟花在做核酸上,完全可以多做二三十人的分量。所以我们就有了做一个自动消毒机的念头。

²  制作步骤

1.将木板和四根小圆柱做成支架。 

2.将设备粘在支架上。

3.将水泵粘在支架上并连接水管与电源。在水管上装上喷头。

4.制作代码。 

5.导入主控板

²  硬件清单

1.    arduino UNO 主控板

2.    Arduino UNO 扩展板

3.    1602 icc显示屏

4.    8*8 点阵模块

5.    按键模块(红,黄)

6.    水管x2

7.    超声波传感器

8.    水泵x2

9.    继电器x2

10.电源(电池)

11.蜂鸣器x1

²  接线图

 

附件

    评论

    user-avatar
    • 双鱼

      双鱼2022.08.14

      牛逼

      0
      • 双鱼

        双鱼2022.08.14

        666

        0