创意说明:当前正值新冠疫情背景下的个别地方的防疫,公共场所洗手是个大问题。一方面,大家赶时间,且多半还是手动接触开关。为避免人员扎堆,免去交叉感染的风险,本装置试图用基本的开源硬件支持下,以解决洗手问题。这类创客项目很多,但是实际会发现一个大问题是普通伺服电机无法按动洗手液按压头,这里的伺服用的是df的18kg的特殊伺服。从伺服摆臂上加一段铁丝并绑在 


原理:本装置有免洗消毒液正面挂开源电子套件(伺服、MP3模块),当超声波传感器测得3M内有障碍(人),即启动MP3模块播放防疫知识,进而启动伺服电机,压下洗手液。当障碍(人)移开,mp3模块关闭,伺服也停止工作。直到下一次的触发。 硬件清单:免洗消毒液、Arduino主板一块、arduino sensor board、充电电源、微波运动传感器一个、杜邦线若干、DF的MP3模块一个 硬件图片如下 
arduino sensor module 
DF mp3模块 
微波运动传感器 https://wiki.dfrobot.com.cn/index.php?title=(SKU:SEN0192)_Microwave_sensor%E5%BE%AE%E6%B3%A2%E4%BC%A0%E6%84%9F%E5%99%A8%E6%A8%A1%E5%9D%97
============== 大功率5v伺服电机 
DF15MG舵机 升级版 实超15KG https://www.dfrobot.com.cn/goods-222.html ==================== 下面是连线图 
=================== 微波模块非常灵敏,需要调整它的灵敏度以适应实际使用场合 
微波运动传感器上有个旋钮可以调整灵敏度。 ===================== 下面是代码 [mw_shl_code=applescript,false]/*
This sketch is made by gada888
From Luoyang,China
2020-04-25
Happy Hacking
*/
#include <SoftwareSerial.h>
SoftwareSerial Serial1(10, 11);// RX, TX
unsigned char order[4] = {0xAA,0x06,0x00,0xB0};
/////////////initialize servo///////////////
#include <Servo.h>
Servo myservo;
#include <MsTimer2.h> //Timer interrupt function
int pbIn = 0; // Define the interrupt PIN is 0, that is, digital pins 2
int ledOut = 13;
//int piezoPin = 8;
int count=0;
volatile int state = LOW; //Define ledOut, default is off
void setup()
{
Serial.begin(9600);
Serial1.begin(9600);
volume(0x1E);
myservo.attach(9);
attachInterrupt(pbIn, stateChange, FALLING); // Sets the interrupt function, falling edge triggered interrupts.
MsTimer2::set(1000,process); // Set the timer interrupt time 1000ms
MsTimer2::start();//Timer interrupt start
}
void loop()
{
Serial.println(count); // Printing times of 1000ms suspension
delay(1);
if(state == HIGH) //When moving objects are detected later, 2s shut down automatically after the ledout light is convenient.
{
delay(2000);
state = LOW;
myservo.write(130);
play(0x01);
delay(1000);
}
}
void stateChange() //Interrupt function
{
count++;
}
void process() //Timer handler
{
if(count>1) //1000ms interrupt number greater than 1 is considered detected a moving object (this value can be adjusted according to the actual situation, equivalent to adjust the detection threshold of the speed of a moving object)
{
state = HIGH;
myservo.write(0);
count=0; //Count zero
}
else
count=0; //In 1000ms, interrupts does not reach set threshold value is considered not detect moving objects, interrupt the count number is cleared to zero.
}
void play(unsigned char Track)
{
unsigned char play[6] = {0xAA,0x07,0x02,0x00,Track,Track+0xB3};
Serial1.write(play,6);
}
void volume( unsigned char vol)
{
unsigned char volume[5] = {0xAA,0x13,0x01,vol,vol+0xBE};
Serial1.write(volume,5);
}[/mw_shl_code]
|