亲,“电路城”已合并升级到更全、更大、更强的「新与非网」。点击查看「新与非网」

本网页已闲置超过3分钟,按键盘任意键或点击空白处,即可回到网页

专为老年人设计的基于Arduino Nano专用老式提醒闹钟

发布时间:2021-07-01
分享到:

专为老年人设计的基于Arduino Nano专用老式提醒闹钟

发布时间:2021-07-01
分享到:

我们都至少认识一位老人。也许是家人或朋友。随着年龄的增长,他们中的一些人认为我们不在乎他们,而我们真的很爱他们。

一个真正的大问题是,数以百万计的人开始忘记一些事情,比如吃药。

我们可以整天告诉他们做一些事情,但相反,我们可以委派和自动化这项任务。

介绍 Remind-Ino!

它的目的是提醒人们在您无法完成的特定时间完成任务。
它还可以讲故事、阅读书籍、教授烹饪食谱,甚至可以再现歌曲。
它有一种复古的收音机风格,可以记住过去的美好时光。
它有一个简单的界面,1 个扬声器作为输出,1 个按钮作为输入告诉它停止。如果用户没有听到,Remindino 会重复,直到他按下按钮或 5 分钟过去。

您只需要记录警报、保存警报、对 arduino 进行编程、连接电缆、制作一个案例,您就可以开始了!

视频展示

补给品准备
-1 x Arduino Nano

-1 x RTC 模块

-1 x MP3 模块(DFrobot 或 TF-16P)

-1 x 按钮

-1 x 8[ohm] 0.5 [W] 扬声器或类似设备

-4 x 1[Kohm] 电阻

-1 x 迷你面包板

-各种公母跳线

-1 x SD 卡(32 GB,取决于大小)

-烙铁

-FoamBoard 和工具或 3D 打印机和灯丝或任何你想制作外壳的东西。

第 1 步:设置警报

对于警报,我们只有 2 个限制:SD 卡存储容量,它们必须是 mp3 文件。

该 mp3 文件将随着警报的编程而复制。它们可以是您自己、家人、朋友、音乐、书籍、播客或您希望闹钟响起的任何内容的录音。需要注意的一件事是必须为整个月设置警报。接下来要考虑的是:

每天在指定的时间会有相同数量的闹钟,但根据日期的不同,闹钟的 mp3 文件可能相同或不同。例如:

我们定义将有 4 个警报:9:00 的警报 1、10:30 的警报 2、14:00 的警报 3 和 17:25 的警报 4。

但是我们可以根据一天播放不同的音频:

本月1日:

警报 1是芝士蛋糕食谱(例如:解释如何制作芝士蛋糕的 mp3 文件)

警报 2是服用药物(例如:告诉他们必须服用什么药物的 mp3 文件)

本月2:

警报 1是占星术之书(例如:mp3 文件,该文件为初学者阅读占星术第 1 章)

警报 2是服用药物(例如:告诉他们必须服用什么药物的 mp3 文件)

上面的例子您懂了吗?

因此,完成警报的步骤如下:

  1. 定义整个月需要的时间和警报
  2. 记录并拥有所有mp3 文件
  3. 在 SD 卡的目录中创建所有日期的文件夹 (01,02,...,30,31)
  4. 根据日期将 mp3 文件保存在每个文件夹中,如下所示: 对于文件夹 01 Cheesecake alarm 必须保存为 001.mp3,Take Medicines alarm 必须保存为 002.mp3。对于文件夹02 Astrology alarm必须保存为001.mp3,Take Medicines alarm必须保存为002.mp3等等。

第 2 步:电路

电路就是这么简单。

连接的时候要小心。我在寻找有关如何使用 MP3 模块的好教程时遇到了麻烦,如果某些东西不起作用,则可能是您颠倒了它的顺序。

我也在努力寻找如何将 mp3 文件保存在 SD 卡中,但我已经在警报步骤中解释了如何做到这一点。

MP3 模块也不支持 5V 的通信,这就是为什么我使用带有电阻的分压器并且它工作得很好。

第 3 步:Arduino 代码

代码在Arduino平台上实现:

首先,我们需要安装库以使用不同的模块。您可以从 arduino 管理面板安装它们。点击查看如何操作。下面是可以详细代码

#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
#include <Wire.h>
#include <RTClib.h>

然后我们需要声明将需要的通用变量。

RTC_DS3231 rtc;
SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;

对于报警变量,我们稍微解释一下:

//Here you need to put at what time the alarms will start to play. WARNING: Put more >= 10 minutes in between alarms!
//For example:
//  9:00 Alarm 1
//  11:25 Alarm 2
//  15:00 Alarm 3
//  19:30 Alarm 4
//  Hours[]={9,11,15,19};
//  Minutes[]={0,25,0,30};
//  Sono[4];
//  hour_reset=5; Earlier than the first alarm (9:00)

int Hours[]={21,21,21,21,21,21}; //Here you need to put the hours of the alarms in consecutive order
int Minutes[]={4,5,6,8,10,11}; //Here you need to put the minutes of the alarms in consecutive order
int Sono[6];//Here you need to put how many alarms you chose
int hour_reset=4;//Its the time where all the alarms will reset and start a new day. It must be earlier than your first alarm.

以及其他一些变量。

boolean sonando = false;
boolean presionado=false;
int numero_alarma = 0;
int Day=1;

然后我们有一些函数,比如一个在按下按钮时处理中断的函数,另一个使 mp3 模块播放音频。

void tocar_alarma(int numero_alarma,int Day){
  myDFPlayer.playFolder(Day,(numero_alarma+1)); 
}

void Button_Pressed(){
  if(sonando=true){
    presionado=true;  
  } 
}

然后我们进行了设置,我们设置了 mp3 模块、外部中断和 RTC 模块。这个很重要。首先,您需要将 RTC 模块设置为实时。您可以按照本教程进行操作。在设置中,我们还根据时间告诉 arduino 下一个警报。

void setup()
{

  mySoftwareSerial.begin(9600);
  Serial.begin(9600);


  pinMode(3, INPUT);
  attachInterrupt(1, Button_Pressed, RISING);


  Serial.println();
  Serial.println(F("DFRobot DFPlayer Mini Demo"));  
  if (!myDFPlayer.begin(mySoftwareSerial)) {  
    Serial.println(F("Unable to begin:"));
    Serial.println(F("1.Please recheck the connection!"));
    Serial.println(F("2.Please insert the SD card!"));
    while(true);
  }
  Serial.println(F("DFPlayer Mini online."));
  myDFPlayer.setTimeOut(500); 
  myDFPlayer.volume(15); // Here you can set the volum of the speaker! (0-30) 
  myDFPlayer.EQ(DFPLAYER_EQ_NORMAL);
  myDFPlayer.outputDevice(DFPLAYER_DEVICE_SD);


  delay(3000);
  if (! rtc.begin()){
    Serial.println("No hay un módulo RTC");
    while (1);
  }


//  *********** Check When We Are?

  DateTime now = rtc.now();
  int c=0;
  while(Hours[c]!=0){
    if(Hours[c]<now.hour()){
      c++;
    }else if(Hours[c]==now.hour()){
      if(Minutes[c]<now.minute()){
        c++;
      }else if(Minutes[c]==now.minute()){
        c++;
      }else{
        numero_alarma=c;
        break;  
      }
    }else{
      numero_alarma=c;
      break;
    }
  }
}

接下来,我们有一个循环,其中进行时间检查和播放警报:

void loop()
{
// Get real time from RTC
  DateTime now = rtc.now();
  delay(1000);
  Day=now.day();

  Serial.println(now.minute());
  Serial.println(now.second());
  Serial.println(numero_alarma);

//  Reset before the first alarm
  if(now.hour()==hour_reset && now.minute()==0){
    numero_alarma = 0;
    sonando = false;
    presionado=false;
    int Sono[5];  
  }

//  If its time of alarm, play the alarm
  if(now.hour()==Hours[numero_alarma] && now.minute()==Minutes[numero_alarma] && Sono[numero_alarma]==0){
     tocar_alarma(numero_alarma,Day); 
     Sono[numero_alarma]=1;
     sonando = true;  
  }

//  Check if in 5 minutes nobody pressed the button
  int min_test=0;
  int time_reset=5; // Time that button isn't pressed
  if(Minutes[numero_alarma]>=(60-time_reset)){
    min_test=time_reset-(60-Minutes[numero_alarma]);
  }else{
    min_test=Minutes[numero_alarma]+time_reset;
  }
  if(sonando==true && min_test<=now.minute()){
    Serial.println("ENTRO!");
    Serial.println(Minutes[numero_alarma]+5);
    presionado=true;

  //  *********** Check When We Are?
    DateTime now = rtc.now();
    int c=0;
    while(Hours[c]!=0){
      if(Hours[c]<now.hour()){
        c++;
      }else if(Hours[c]==now.hour()){
        if(Minutes[c]<now.minute()){
          c++;
        }else if(Minutes[c]==now.minute()){
          c++;
        }else{
          numero_alarma=c;
          break;  
        }
      }else{
        numero_alarma=c;
        break;
      }
    }  
  }

就是这样。检查文档很棒,您可以访问模块制造商的页面。

完整代码:

//***********           ***********
//*********** Libraries ***********
//***********           ***********

#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
#include <Wire.h>
#include <RTClib.h>

//***********           ***********
//*********** Variables ***********
//***********           ***********

RTC_DS3231 rtc;
SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;


//**********        **********
//********** Alarms **********
//**********        **********
//Here you need to put at what time the alarms will start to play. WARNING: Put more >= 10 minutes in between alarms!
//For example:
//  9:00 Alarm 1
//  11:25 Alarm 2
//  15:00 Alarm 3
//  19:30 Alarm 4
//  Hours[]={9,11,15,19};
//  Minutes[]={0,25,0,30};
//  Sono[4];
//  hour_reset=5; Earlier than the first alarm (9:00)

int Hours[]={21,21,21,21,21,21}; //Here you need to put the hours of the alarms in consecutive order
int Minutes[]={4,5,6,8,10,11}; //Here you need to put the minutes of the alarms in consecutive order
int Sono[6];//Here you need to put how many alarms you chose
int hour_reset=4;//Its the time where all the alarms will reset and start a new day. It must be earlier than your first alarm.

boolean sonando = false;
boolean presionado=false;
int numero_alarma = 0;
int Day=1;

//***********           ***********
//*********** Functions ***********
//***********           ***********
void tocar_alarma(int numero_alarma,int Day){
  myDFPlayer.playFolder(Day,(numero_alarma+1)); 
}

void Button_Pressed(){
  if(sonando=true){
    presionado=true;  
  } 
}

//***********            ***********
//*********** Void Setup ***********
//***********            ***********

void setup()
{

  mySoftwareSerial.begin(9600);
  Serial.begin(9600);


  pinMode(3, INPUT);
  attachInterrupt(1, Button_Pressed, RISING);


  Serial.println();
  Serial.println(F("DFRobot DFPlayer Mini Demo"));  
  if (!myDFPlayer.begin(mySoftwareSerial)) {  
    Serial.println(F("Unable to begin:"));
    Serial.println(F("1.Please recheck the connection!"));
    Serial.println(F("2.Please insert the SD card!"));
    while(true);
  }
  Serial.println(F("DFPlayer Mini online."));
  myDFPlayer.setTimeOut(500); 
  myDFPlayer.volume(15); // Here you can set the volum of the speaker! (0-30) 
  myDFPlayer.EQ(DFPLAYER_EQ_NORMAL);
  myDFPlayer.outputDevice(DFPLAYER_DEVICE_SD);

第 4 步:制作案例(老式收音机)

该案例考虑了最终用户的体验。在这种情况下,最终用户将是老年人,在您的情况下可能有所不同。

这部分非常有创意!
正如我们之前所说,我们的最终用户是一位老人,这就是为什么决定外壳必须具有 Vintage Radio 风格的原因。因为他们喜欢那样。

1.先做了一点研究!
2.然后使用最好的3D CAD建模软件设计模型:Autodesk Fusion 360!!!

在这里,您必须根据组件的大小来设计模型。您必须测量您的按钮和扬声器直径才能打出完美的孔。这部分真的取决于你。您可以根据您的测量使用模型并固定尺寸。您可以 3D 打印您的模型,也可以将其设计为在泡沫板上制作,就像我的情况一样。

3.模型完成后,可以进行3D打印,也可以打印零件的图纸作为模板切割成泡沫板。关于如何切割泡沫板的教程
4. 然后你需要给所有的部分上色,这样你就可以给它你想要的风格。就我而言,我看到了这个人造木头绘画教程,让它看起来复古而古老。
5. 你可以给它额外的装饰,比如贴花、网眼织物和一些额外的东西,让它更有吸引力!

复古收音机 .f3d 点击下载

第 5 步:组装和测试

在这部分中,您应该将每个组件放入机箱并测试它的声音。如果用户感觉舒适,您可以检查警报。您还需要检查代码的无效设置中的音量。

检查所有连接,因为如果连接不正确,电子设备可能会损坏和烧毁,并且无法工作。

此时,如果一切都按计划进行,恭喜您已完成 Remind-Ino的制作!

 

加入微信技术交流群

技术交流,职业进阶

关注与非网服务号

获取电子工程师福利

加入电路城 QQ 交流群

与技术大牛交朋友

讨论