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

【暖冬行动】无接触测温&洗手魔盒 简单

头像 白凡 2020.11.12 3560 13
project-image

【灵感来源】

随着冬天的到来,新冠病毒在海外有一次掀起了一波大传染。国内也出现了零星的输入病例,学校里面的防控力度也逐步开始恢复。

某次在班级里看学生排队测温以及使用免水洗洗手液时,学生一个接着一个连着去按洗手液,各种交叉接触。于是产生了一个想法,怎么让学生真正意义上的“无接触”使用洗手液呢?

project-image

【设计原理】

测温模块——红外线传感器反馈室温和提问,通过arduino开发板导入对应脚本,在OLED上实时显示。

洗手模块——超声波传感器感应手靠近,在arduino开发板中导入对应脚本,控制舵机旋转实现洗手液容器自动挤压出水,同时在LCD显示器上显示提示信息。

project-image
project-image

【图片说明】

project-image
project-image
project-image
project-image

【模型展示】

project-image

【视频演示】

(录了一段学生排队使用的视频,这里就不放出来了,毕竟都露脸的,涉及到学生的隐私。(放个图吧))

project-image

材料清单

  • arduino开发板(nano和uno) X2
  • 电池组 X2
  • LCD显示器 X1
  • OLED显示器 X1
  • 红外测温模块 X1
  • 180度舵机 X1
  • 超声波传感器 X1
  • 免水洗消毒洗手液 X1
  • 蜂鸣器 X1

【测温部分程序】

代码
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <stdint.h>
#include <Adafruit_MLX90614.h>

#define SCREEN_WIDTH 128 // OLED屏的宽,128个像素点
#define SCREEN_HEIGHT 64 // OLED屏的高,64个像素点
#define OLED_RESET 4
 
Adafruit_SSD1306 display(OLED_RESET);
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
int z = 4.0 ;

 
void setup()   
{                
  Serial.begin(9600);
  pinMode(7, OUTPUT);
  
  Serial.println("Adafruit MLX90614 test");  
  mlx.begin();  
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  //屏幕的IIC地址为0X3C
}
 
 
void loop() 
{


  Serial.println("Temperature from MLX90614:");
  Serial.print("Ambient:      ");
  Serial.print(mlx.readAmbientTempC());
  Serial.println(" °C");
  Serial.print("Contactless: ");
  Serial.print(mlx.readObjectTempC());
  Serial.println(" °C");
  Serial.println();
  delay(1000);


  
  display.clearDisplay(); //清屏
 
  display.setTextSize(1); //设置字体大小
  display.setTextColor(WHITE); //设置颜色
  display.setCursor(0,0);
  display.print("Ambient: ");
  display.print(mlx.readAmbientTempC()); //显示环境温度
  display.print("C");
  display.setCursor(0,10);
  display.print("Object: ");
  display.print(mlx.readObjectTempC()+ z);  //显示目标温度
  display.print("C");
  display.display();

  if(mlx.readObjectTempC()+z > 34.5 && mlx.readObjectTempC()+z<37.5)     //传感器测出的目标温度+修正值在正常体温范围
  {
          delay(10);
          tone(7, 1000);              //蜂鸣器提示
          delay(200);
          tone(7, 1200);
          delay(200);
          noTone(7);
  }
if(mlx.readObjectTempC()+z > 37.6)  //体温超过正常值
{
          delay(10);
          tone(7, 1100);              //蜂鸣器“报警”
          delay(100);
          tone(7, 1300);
          delay(100);
          tone(7, 1100);              
          delay(100);
          tone(7, 1300);
          delay(100);
          tone(7, 1100);              
          delay(100);
          tone(7, 1300);
          delay(100);
          tone(7, 1100);              
          delay(100);
          tone(7, 1300);
          delay(100);
          noTone(7);
  }

 
  delay(2000);
  
}

【洗手部分程序】

代码
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <NewPing.h>
#include <Servo.h>

LiquidCrystal_I2C lcd(0x27,16,2);//0x27   0x3F

#define TRIGGER_PIN  2  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN     3  // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 400 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.


Servo myservo;
int pos = 0;

String returntemp = "";           //存储返回值 
int g_UTL = 0;
int shezhi = 7;                   //预设距离
int fre;//set the variable to store the frequence value

/*printf格式化字符串初始化*/
int serial_putc( char c, struct __file * )
{
  Serial.write( c );
  return c;
}
void printf_begin(void)
{
  fdevopen( &serial_putc, 0 );
}

void setup()
{
  myservo.attach(9);
  
  lcd.init(); 
  lcd.backlight();
  Serial.begin(9600);	          //波特率9600 
  printf_begin();                 //初始化printf
}


void loop() 
{   
 TP1:   
    delay(100); 
    unsigned int uS = sonar.ping();    
    g_UTL =  uS / US_ROUNDTRIP_CM;
    if (g_UTL == 0) goto TP1;   //误判
    
    lcd.setCursor(0, 0);
    lcd.print("Tips    :");
    lcd.setCursor(0, 1);
    lcd.print("             ");
    lcd.setCursor(2, 1);
    lcd.print("Close to use  ");            //提示:靠近后使用


     if(g_UTL < shezhi)         //如果检测到的超声波距离值小于设定的超声波距离值
     {
   
      delay(1000);
      lcd.setCursor(0, 0);
      lcd.print("Tips    :");
      lcd.setCursor(0, 1);
      lcd.print("                ");
      lcd.setCursor(1, 1);
      lcd.print("Please use it");           //提示:请使用
      delay(2000);
      for (pos = 0; pos <= 180; pos += 1) {        //舵机旋转从0度-180度
      myservo.write(pos);              
      delay(10);                      
  
      }
      delay(1000);
      
      for (pos = 180; pos >= 0; pos -= 1) {        // 180度-0度
      myservo.write(pos);              
      delay(10);                       

      } 

   delay(2000); 
     }
}

PS:感谢论坛上的大佬们分享的经验,一直默默潜水学习,最近在带学生创客类项目,下一个创意尝试让学生团队自己来做做看。

评论

user-avatar
  • cinderella

    cinderella2022.03.07

    大神,舵机是哪种型号的,我们学生买的舵机力度不够,能发下品牌和型号吗?

    0
    • 帅哥66

      帅哥662021.05.10

      大神,我也想做一个出来,可以加你详细的教教我吗

      1
      • 白凡

        白凡2021.09.10

        不好意思,回复晚了,这个盒子的模型文件就是那个hezi.rsdoc,尺寸其实有点大的,可以适当微调

    • 帅哥66

      帅哥662021.05.10

      大神,造这个魔盒的尺寸数据有吗

      0
      • 帅哥66

        帅哥662021.05.10

        这个魔盒

        0
        • 帅哥66

          帅哥662021.05.10

          大神,请问这个盒子是3D打印造出来的吗

          0
          • gylst

            gylst2020.12.24

            大神,没看到lcd显示屏有啥用,然后能发一下材料的型号吗

            1
            • 白凡

              白凡2021.01.13

              LCD的作用是提示信息,比如:close to use 和 please use it 提示超声波测距的状态。材料型号的话,其实常规网上能买到的都能用,区别不大。

          • 白凡

            白凡2020.11.28

            我这个作品今天拿去参加本区的教师创客作品评比了,希望能拿个好成绩!

            0
            • hnyzcj

              hnyzcj2020.11.16

              哈哈哈好

              1
              • 白凡

                白凡2020.11.17

                大神你好!

            • rzegkly

              rzegkly2020.11.15

              创意十足

              0
              • 1111111

                11111112020.11.13

                很棒的设计。

                0