本帖最后由 DFSH_Cranberry 于 2021-1-25 16:14 编辑
中老年人智能药盒 目录 一、背景介绍
二、市场调研
三、产品功能
四、硬件代码
五、产品外观
六、市场定位
一、背景介绍 本着生命第一,健康第一的原则,本款产品解决部分中老年人在用药上做了充分市场调研,以及较全面功能应用分析,旨在能够提高中老年人生活质量。 目标:为提醒需要定时吃药的健忘中老年人 常见用户痛点: - 中老年人容易忘记吃药时间。
- 中老年人容易忘记把药放在什么位置。
二、市场调研 我们调查发现:(常见中老年人疾病以及用药时间) 图一 根据图一,我们不难发现,不同的患者他们有着不同的用药时间。高血压患者是每天都需要吃药,而且每天用药的时间也是不一样的;像高血脂患者,他们用药时间一般是十天到半个月,属于较长周期性疗程用药。
三、产品功能 友商产品:时间显示,设置每天定时闹钟 我们的产品: - 一键记录当前时间(特色,中老年人智能记录时间模式)
- 功能齐全(时间设置,定时闹钟,指定日期闹钟)
特色:对于每天需要吃药的中老年人,为了简化设置闹钟时间,我们采用一键式记录当前时间,避免因为操作困难给中老年人带来困扰,用户只需要在头次吃药的时候准时按键记录,后面每天都可以在同一时间进行智能提醒。 产品功能详细介绍见图二:
四、硬件代码 硬件 - FireBeetle 萤火虫 ESP32微控制器 X 1
(https://www.dfrobot.com.cn/goods-1394.html) (https://www.dfrobot.com.cn/goods-1696.html) (https://www.dfrobot.com.cn/goods-611.html) (https://www.dfrobot.com.cn/goods-78.html) - I2C SD2405 RTC 实时时钟模块 X 1
(https://www.dfrobot.com.cn/goods-1405.html) (https://www.dfrobot.com.cn/goods-534.html) (https://www.dfrobot.com.cn/goods-2831.html) 接线图: 代码:
- #include "GravityRtc.h"
- #include <Wire.h>
- #include "DFRobot_LCD.h"
- GravityRtc rtc;
- DFRobot_LCD lcd(16,2); //16 characters and 2 lines of show
- int button_13 = D7;
- int button_12 = D3;
- int button_11 = D2;
- int a[4][3]={{0,0,0},{0,0,0},{0,0,0},{0,0,0}}; //remenber the time currently
- int b[4][3]={{0,0,0},{0,0,0},{0,0,0},{0,0,0}}; //remenber the time by habit
- int c[4][6]={{2020,9,7,0,0,0},{2020,9,7,0,0,0},{2020,9,7,0,0,0},{2020,9,7,0,0,0}}; //set the time of periodicity
- #define NOTE_D0 -1
- #define NOTE_D1 294
- #define NOTE_D2 330
- #define NOTE_D3 350
- #define NOTE_D4 393
- #define NOTE_D5 441
- #define NOTE_D6 495
- #define NOTE_D7 556
-
- #define NOTE_DL1 147
- #define NOTE_DL2 165
- #define NOTE_DL3 175
- #define NOTE_DL4 196
- #define NOTE_DL5 221
- #define NOTE_DL6 248
- #define NOTE_DL7 278
-
- #define NOTE_DH1 589
- #define NOTE_DH2 661
- #define NOTE_DH3 700
- #define NOTE_DH4 786
- #define NOTE_DH5 882
- #define NOTE_DH6 990
- #define NOTE_DH7 112
- //以上部分是定义是把每个音符和频率值对应起来,其实不用打这么多,但是都打上了,后面可以随意编写D调的各种歌,我这里用NOTE_D+数字表示音符,NOTE_DH+数字表示上面有点的那种音符,NOTE_DL+数字表示下面有点的那种音符。这样后面写起来比较好识别。
- #define WHOLE 1
- #define HALF 0.5
- #define QUARTER 0.25
- #define EIGHTH 0.25
- #define SIXTEENTH 0.625
- //这部分是用英文对应了拍子,这样后面也比较好看
- int tune[] =
- {
- NOTE_DH1,NOTE_D6,NOTE_D5,NOTE_D6,NOTE_D0,
- NOTE_DH1,NOTE_D6,NOTE_D5,NOTE_DH1,NOTE_D6,NOTE_D0,NOTE_D6,
- NOTE_D6,NOTE_D6,NOTE_D5,NOTE_D6,NOTE_D0,NOTE_D6,
- NOTE_DH1,NOTE_D6,NOTE_D5,NOTE_DH1,NOTE_D6,NOTE_D0,
-
- NOTE_D1,NOTE_D1,NOTE_D3,
- NOTE_D1,NOTE_D1,NOTE_D3,NOTE_D0,
- NOTE_D6,NOTE_D6,NOTE_D6,NOTE_D5,NOTE_D6,
- NOTE_D5,NOTE_D1,NOTE_D3,NOTE_D0,
- NOTE_DH1,NOTE_D6,NOTE_D6,NOTE_D5,NOTE_D6,
- NOTE_D5,NOTE_D1,NOTE_D2,NOTE_D0,
- NOTE_D7,NOTE_D7,NOTE_D5,NOTE_D3,
- NOTE_D5,
- NOTE_DH1,NOTE_D0,NOTE_D6,NOTE_D6,NOTE_D5,NOTE_D5,NOTE_D6,NOTE_D6,
- NOTE_D0,NOTE_D5,NOTE_D1,NOTE_D3,NOTE_D0,
- NOTE_DH1,NOTE_D0,NOTE_D6,NOTE_D6,NOTE_D5,NOTE_D5,NOTE_D6,NOTE_D6,
- NOTE_D0,NOTE_D5,NOTE_D1,NOTE_D2,NOTE_D0,
- NOTE_D3,NOTE_D3,NOTE_D1,NOTE_DL6,
- NOTE_D1,
- NOTE_D3,NOTE_D5,NOTE_D6,NOTE_D6,
- NOTE_D3,NOTE_D5,NOTE_D6,NOTE_D6,
- NOTE_DH1,NOTE_D0,NOTE_D7,NOTE_D5,
- NOTE_D6,
- };//这部分就是整首曲子的音符部分,用了一个序列定义为tune,整数
-
- float duration[]=
- {
- 1,1,0.5,0.5,1,
- 0.5,0.5,0.5,0.5,1,0.5,0.5,
- 0.5,1,0.5,1,0.5,0.5,
- 0.5,0.5,0.5,0.5,1,1,
-
- 1,1,1+1,
- 0.5,1,1+0.5,1,
- 1,1,0.5,0.5,1,
- 0.5,1,1+0.5,1,
- 0.5,0.5,0.5,0.5,1+1,
- 0.5,1,1+0.5,1,
- 1+1,0.5,0.5,1,
- 1+1+1+1,
- 0.5,0.5,0.5+0.25,0.25,0.5+0.25,0.25,0.5+0.25,0.25,
- 0.5,1,0.5,1,1,
- 0.5,0.5,0.5+0.25,0.25,0.5+0.25,0.25,0.5+0.25,0.25,
- 0.5,1,0.5,1,1,
- 1+1,0.5,0.5,1,
- 1+1+1+1,
- 0.5,1,0.5,1+1,
- 0.5,1,0.5,1+1,
- 1+1,0.5,0.5,1,
- 1+1+1+1
- };//这部分是整首曲子的接拍部分,也定义个序列duration,浮点(数组的个数和前面音符的个数是一样的,一一对应么)
- int freq = 2000;
- int channel = 0;
- int resolution = 8;
- void setup() {
- pinMode(button_11,INPUT);
- pinMode(button_12,INPUT);
- pinMode(button_13,INPUT);
- ledcSetup(channel, freq, resolution);
- ledcAttachPin(D6, channel);
- Serial.begin(9600);
- rtc.setup();
- //自动设置RTC时钟:通过获取电脑时间校准RTC模块,首先需要保证电脑时间正确
- rtc.adjustRtc(F(__DATE__), F(__TIME__));
- // initialize
- lcd.init();
- // Print a message to the LCD.
-
-
- }
-
- void loop() {
- time_appearence();
- if(digitalRead(button_13)==HIGH){
- delay(200);
- int flag_TandA=0;
- while(1){ //选择时间调节模式还是闹钟调节模式
- if(digitalRead(button_12)==HIGH){
- flag_TandA=1+flag_TandA;
- delay(200);
- }
- if(flag_TandA%4==0){
- lcd.setCursor(0, 0);
- lcd.print("time adjust ");
- lcd.setCursor(0, 1);
- lcd.print(" ");
- }else if(flag_TandA%4==1){
- lcd.setCursor(0, 0);
- lcd.print("alarm adjust ");
- lcd.setCursor(0, 1);
- lcd.print(" ");
- }else if(flag_TandA%4==2){
- lcd.setCursor(0, 0);
- lcd.print("set a date ");
- lcd.setCursor(0, 1);
- lcd.print(" ");
- }else{
- lcd.setCursor(0, 0);
- lcd.print("close all alarms");
- lcd.setCursor(0, 1);
- lcd.print(" ");
- }
- if(digitalRead(button_13)==HIGH){ //make a sure
- delay(200);
- if(flag_TandA%4==0){
- RTC_adjust(); // time adjust
- break;
- }else if(flag_TandA%4==1){
- AC_adjust(); //set a currently AC time
- break;
- }else if(flag_TandA%4==2){
- fix_a_date(); //set a periodicity time
- break;
- }else{
- DAC_FAD(); //del all the alarm clock
- break;
- }
- }
- if(digitalRead(button_11)==HIGH){ //return
- delay(200);
- break;
- }
- }
- }
- delay(200);
- if(digitalRead(button_12)==HIGH){
- delay(200);
- IRA(); //remenber a time automaticly
- }
- if(digitalRead(button_11)==HIGH){
- delay(200);
- DIRA(); //del all the automaticly time
- }
- AC_judge(); //jugle the time in order to make a alarm or not
- }
-
- //DEL all the alarm clock
- void DAC_FAD(){
- lcd.setCursor(0, 1);
- lcd.print("valid or not ");
- lcd.setCursor(12, 1);
- lcd.print(" ");
- int DAC_FAD_value;
- DAC_FAD_value=0;
- while(1){
- if(DAC_FAD_value==0){
- lcd.setCursor(13, 1);
- lcd.print("F");
- }else{
- lcd.setCursor(13, 1);
- lcd.print("T");
- }
- delay(200);
- if(digitalRead(button_13)==HIGH){
- if(DAC_FAD_value==1){
- for(int i=0;i<4;i++){
- a[i][2]=0;
- }
- for(int i=0;i<4;i++){
- c[i][5]=0;
- }
- delay(100);
- break;
- }else{
- delay(100);
- break;
- }
- }
- if(digitalRead(button_12)==HIGH){
- DAC_FAD_value=1-DAC_FAD_value;
- delay(100);
- }
- if(digitalRead(button_11)==HIGH){
- DAC_FAD_value=1-DAC_FAD_value;
- delay(100);
- }
- }
- }
-
- //set a periodicity time
- void fix_a_date(){
- int flag_fix=0;
- int F_value=0;
- while(1){
- if(digitalRead(button_12)==HIGH){
- delay(100);
- flag_fix=1+flag_fix;
- }
- if(flag_fix%4==0){
- lcd.setCursor(0, 0);
- lcd.print("set one date ");
- lcd.setCursor(0, 1);
- lcd.print(" ");
- }else if(flag_fix%4==1){
- lcd.setCursor(0, 0);
- lcd.print("set two date ");
- lcd.setCursor(0, 1);
- lcd.print(" ");
- }else if(flag_fix%4==2){
- lcd.setCursor(0, 0);
- lcd.print("set three date ");
- lcd.setCursor(0, 1);
- lcd.print(" ");
- }else{
- lcd.setCursor(0, 0);
- lcd.print("set four date ");
- lcd.setCursor(0, 1);
- lcd.print(" ");
- }
- if(digitalRead(button_13)==HIGH){
- delay(200);
- if(flag_fix%4==0){
- F_value=flag_fix%4;
- Fix_adjust(F_value);
- }else if(flag_fix%4==1){
- F_value=flag_fix%4;
- Fix_adjust(F_value);
- }else if(flag_fix%4==2){
- F_value=flag_fix%4;
- Fix_adjust(F_value);
- }else{
- F_value=flag_fix%4;
- Fix_adjust(F_value);
- }
- }
- if(digitalRead(button_11)==HIGH){
- delay(100);
- break;
- }
- }
- }
-
- void Fix_adjust(int F_value){
- int value;
- value=F_value;
- while(1){
- lcd.setCursor(0, 1);
- lcd.print("year");
- lcd.setCursor(5, 1);
- lcd.print(c[value][0]);
- if(digitalRead(button_12)==HIGH){
- delay(200);
- c[value][0]=1+c[value][0];
- }if(digitalRead(button_11)==HIGH){
- delay(200);
- c[value][0]=c[value][0]-1;
- }
- if(digitalRead(button_13)==HIGH){
- delay(200);
- break;
- }
- }
- while(1){
- lcd.setCursor(0, 1);
- lcd.print("month");
- lcd.setCursor(5, 1);
- lcd.print(" ");
- if(c[value][1]<10){
- lcd.setCursor(6, 1);
- lcd.print(c[value][1]);
- lcd.setCursor(7, 1);
- lcd.print(" ");
- }else{
- lcd.setCursor(6, 1);
- lcd.print(c[value][1]);
- }
- if(digitalRead(button_12)==HIGH){
- delay(200);
- c[value][0]=1+c[value][0];
- if(c[value][1]==13){
- c[value][1]=1;
- }
- }if(digitalRead(button_11)==HIGH){
- delay(200);
- c[value][1]=c[value][1]-1;
- if(c[value][1]==0){
- c[value][0]=12;
- }
- }
- if(digitalRead(button_13)==HIGH){
- delay(200);
- break;
- }
- }
- while(1){
- lcd.setCursor(0, 1);
- lcd.print("day");
- lcd.setCursor(3, 1);
- lcd.print(" ");
- if(c[value][2]<10){
- lcd.setCursor(4, 1);
- lcd.print(c[value][2]);
- lcd.setCursor(5, 1);
- lcd.print(" ");
- }else{
- lcd.setCursor(4, 1);
- lcd.print(c[value][2]);
- }
- if(digitalRead(button_12)==HIGH){
- delay(200);
- c[value][2]=1+c[value][2];
- if(c[value][2]==32){
- c[value][2]=1;
- }
- }if(digitalRead(button_11)==HIGH){
- delay(200);
- c[value][2]=c[value][2]-1;
- if(c[value][2]==0){
- c[value][2]=31;
- }
- }
- if(digitalRead(button_13)==HIGH){
- delay(200);
- break;
- }
- }
- while(1){
- lcd.setCursor(0, 1);
- lcd.print("hour");
- lcd.setCursor(4, 1);
- lcd.print(" ");
- if(c[value][3]<10){
- lcd.setCursor(5, 1);
- lcd.print(c[value][3]);
- lcd.setCursor(6, 1);
- lcd.print(" ");
- }else{
- lcd.setCursor(5, 1);
- lcd.print(c[value][3]);
- }
- if(digitalRead(button_12)==HIGH){
- delay(200);
- c[value][3]=1+c[value][3];
- if(c[value][3]==24){
- c[value][3]=0;
- }
- }if(digitalRead(button_11)==HIGH){
- delay(200);
- c[value][3]=c[value][3]-1;
- if(c[value][3]==-1){
- c[value][3]=23;
- }
- }
- if(digitalRead(button_13)==HIGH){
- delay(200);
- break;
- }
- }
- while(1){
- lcd.setCursor(0, 1);
- lcd.print("minute");
- lcd.setCursor(6, 1);
- lcd.print(" ");
- if(c[value][4]<10){
- lcd.setCursor(7, 1);
- lcd.print(c[value][4]);
- lcd.setCursor(8, 1);
- lcd.print(" ");
- }else{
- lcd.setCursor(7, 1);
- lcd.print(c[value][4]);
- }
- if(digitalRead(button_12)==HIGH){
- delay(200);
- c[value][4]=1+c[value][4];
- if(c[value][4]==60){
- c[value][4]=0;
- }
- }if(digitalRead(button_11)==HIGH){
- delay(200);
- c[value][4]=c[value][4]-1;
- if(c[value][4]==-1){
- c[value][4]=59;
- }
- }
- if(digitalRead(button_13)==HIGH){
- delay(200);
- break;
- }
- }
- while(1){
- lcd.setCursor(0, 1);
- lcd.print("vaild or not");
- lcd.setCursor(12, 1);
- lcd.print(" ");
- if(c[value][5]==0){
- lcd.setCursor(13, 1);
- lcd.print("F");
- }else{
- lcd.setCursor(13, 1);
- lcd.print("T");
- }
- if(digitalRead(button_12)==HIGH){
- c[value][5]=1-c[value][5];
- delay(100);
- }
- if(digitalRead(button_11)==HIGH){
- c[value][5]=1-c[value][5];
- delay(100);
- }
- if(digitalRead(button_13)==HIGH){
- delay(100);
- break;
- }
- }
- }
-
- //remenber a time automaticly
- void IRA(){
- int IRA_flag=0;
- for(int i=0;i<4;i++){
- if(b[i][2]==0){
- b[i][0]=rtc.hour;
- b[i][1]=rtc.minute;
- lcd.setCursor(0, 0);
- lcd.print("remenber time ");
- lcd.setCursor(0, 1);
- lcd.print("valid or not ");
- while(1){
- if(digitalRead(button_13)==HIGH){
- delay(100);
- b[i][2]=1;
- IRA_flag=1;
- break;
- }else if(digitalRead(button_11)==HIGH){
- delay(100);
- break;
- }
- }
- break;
- }
- }
- if(IRA_flag==0){
- lcd.setCursor(0, 0);
- lcd.print("space full ");
- lcd.setCursor(0, 1);
- lcd.print("Please empty it ");
- delay(3000);
- }
- }
-
- //del all the automaticly time
- void DIRA(){
- lcd.setCursor(0, 0);
- lcd.print("space empty ");
- lcd.setCursor(0, 1);
- lcd.print("valid or not ");
- while(1){
- if(digitalRead(button_13)==HIGH){
- delay(200);
- for(int i=0;i<4;i++){
- b[i][2]=0;
- }
- break;
- }
- if(digitalRead(button_11)==HIGH){
- delay(200);
- break;
- }
- }
- }
-
- //显示当前时间
- void time_appearence(){
- rtc.read();
- lcd.setCursor(0, 0);
- lcd.print(rtc.year);
- lcd.setCursor(4, 0);
- lcd.print("/");
- if(rtc.month<10){
- lcd.setCursor(5, 0);
- lcd.print("0");
- lcd.setCursor(6, 0);
- lcd.print(rtc.month);
- }else{
- lcd.setCursor(5, 0);
- lcd.print(rtc.month);
- }
- lcd.setCursor(7, 0);
- lcd.print("/");
- if(rtc.day<10){
- lcd.setCursor(8, 0);
- lcd.print("0");
- lcd.setCursor(9, 0);
- lcd.print(rtc.day);
- }else{
- lcd.setCursor(8, 0);
- lcd.print(rtc.day);
- }
- if(rtc.hour<10){
- lcd.setCursor(0, 1);
- lcd.print("0");
- lcd.setCursor(1, 1);
- lcd.print(rtc.hour);
- }else{
- lcd.setCursor(0, 1);
- lcd.print(rtc.hour);
- }
- lcd.setCursor(2, 1);
- lcd.print("-");
- if(rtc.minute<10){
- lcd.setCursor(3, 1);
- lcd.print("0");
- lcd.setCursor(4, 1);
- lcd.print(rtc.minute);
- }else{
- lcd.setCursor(3, 1);
- lcd.print(rtc.minute);
- }
- lcd.setCursor(5, 1);
- lcd.print("-");
- if(rtc.second<10){
- lcd.setCursor(6, 1);
- lcd.print("0");
- lcd.setCursor(7, 1);
- lcd.print(rtc.second);
- }else{
- lcd.setCursor(6, 1);
- lcd.print(rtc.second);
- }
- lcd.setCursor(9, 1);
- lcd.print("week-");
- lcd.setCursor(14, 1);
- lcd.print(rtc.week);
- lcd.setCursor(10, 0);
- lcd.print(" ");
- lcd.setCursor(8, 1);
- lcd.print(" ");
- lcd.setCursor(15, 1);
- lcd.print(" ");
- delay(200);
- }
-
- //手动设置RTC时钟
- void RTC_adjust(){
- int flag_RTC=0;
- int i_year=rtc.year;
- int i_month=rtc.month;
- int i_day=rtc.day;
- int i_hour=rtc.hour;
- int i_minute=rtc.minute;
- int i_second=rtc.second;
- int i_week=rtc.week;
- while(1){
- if(digitalRead(button_12)==HIGH){
- delay(100);
- flag_RTC=1+flag_RTC;
- }
- if((flag_RTC%7)==0){
- lcd.setCursor(0, 0);
- lcd.print("year adjust ");
- lcd.setCursor(0, 1);
- lcd.print(" ");
- }else if((flag_RTC%7)==1){
- lcd.setCursor(0, 0);
- lcd.print("month adjust ");
- lcd.setCursor(0, 1);
- lcd.print(" ");
- }else if((flag_RTC%7)==2){
- lcd.setCursor(0, 0);
- lcd.print("day adjust ");
- lcd.setCursor(0, 1);
- lcd.print(" ");
- }else if((flag_RTC%7)==3){
- lcd.setCursor(0, 0);
- lcd.print("hour adjust ");
- lcd.setCursor(0, 1);
- lcd.print(" ");
- }else if((flag_RTC%7)==4){
- lcd.setCursor(0, 0);
- lcd.print("minute adjust ");
- lcd.setCursor(0, 1);
- lcd.print(" ");
- }else if((flag_RTC%7)==5){
- lcd.setCursor(0, 0);
- lcd.print("second adjust ");
- lcd.setCursor(0, 1);
- lcd.print(" ");
- }else{
- lcd.setCursor(0, 0);
- lcd.print("week adjust ");
- lcd.setCursor(0, 1);
- lcd.print(" ");
- }
- if(digitalRead(button_13)==HIGH){
- delay(200);
- while((flag_RTC%7)==0){
- lcd.setCursor(0, 0);
- lcd.print("year adjust ");
- lcd.setCursor(0, 1);
- lcd.print(i_year);
- if(digitalRead(button_12)==HIGH){
- i_year=1+i_year;
- }
- if(digitalRead(button_11)==HIGH){
- i_year=i_year-1;
- }
- if(digitalRead(button_13)==HIGH){
- break;
- }
- delay(100);
- }
- while((flag_RTC%7)==1){
- lcd.setCursor(0, 0);
- lcd.print("month adjust ");
- if(i_month<10){
- lcd.setCursor(0, 1);
- lcd.print(i_month);
- lcd.setCursor(1, 1);
- lcd.print(" ");
- }else{
- lcd.setCursor(0, 1);
- lcd.print(i_month);
- }
-
- if(digitalRead(button_12)==HIGH){
- i_month=1+i_month;
- if(i_month==13){
- i_month=1;
- }
-
- }
- if(digitalRead(button_11)==HIGH){
- i_month=i_month-1;
- if(i_month==0){
- i_month=12;
- }
- }
- if(digitalRead(button_13)==HIGH){
- break;
- }
- delay(100);
- }
- while((flag_RTC%7)==2){
- lcd.setCursor(0, 0);
- lcd.print("day adjust ");
- if(i_day<10){
- lcd.setCursor(0, 1);
- lcd.print(i_day);
- lcd.setCursor(1, 1);
- lcd.print(" ");
- }else{
- lcd.setCursor(0, 1);
- lcd.print(i_day);
- }
- if(digitalRead(button_12)==HIGH){
- i_day=1+i_day;
- if(i_day==32){
- i_day=1;
- }
- }
- if(digitalRead(button_11)==HIGH){
- i_day=i_day-1;
- if(i_day==0){
- i_day=31;
- }
- }
- if(digitalRead(button_13)==HIGH){
- break;
- }
- delay(100);
- }
- while((flag_RTC%7)==3){
- lcd.setCursor(0, 0);
- lcd.print("hour adjust ");
- if(i_hour<10){
- lcd.setCursor(0, 1);
- lcd.print(i_hour);
- lcd.setCursor(1, 1);
- lcd.print(" ");
- }else{
- lcd.setCursor(0, 1);
- lcd.print(i_hour);
- }
- if(digitalRead(button_12)==HIGH){
- i_hour=1+i_hour;
- if(i_hour==24){
- i_hour=0;
- }
- }
- if(digitalRead(button_11)==HIGH){
- i_hour=i_hour-1;
- if(i_hour==-1){
- i_hour=23;
- }
- }
- if(digitalRead(button_13)==HIGH){
- break;
- }
- delay(100);
- }
- while((flag_RTC%7)==4){
- lcd.setCursor(0, 0);
- lcd.print("minute adjust ");
- if(i_minute<10){
- lcd.setCursor(0, 1);
- lcd.print(i_minute);
- lcd.setCursor(1, 1);
- lcd.print(" ");
- }else{
- lcd.setCursor(0, 1);
- lcd.print(i_minute);
- }
- if(digitalRead(button_12)==HIGH){
- i_minute=1+i_minute;
- if(i_minute==60){
- i_minute=0;
- }
-
- }
- if(digitalRead(button_11)==HIGH){
- i_minute=i_minute-1;
- if(i_minute==-1){
- i_minute=59;
- }
- }
- if(digitalRead(button_13)==HIGH){
- break;
- }
- delay(100);
- }
- while((flag_RTC%7)==5){
- lcd.setCursor(0, 0);
- lcd.print("second adjust ");
- if(i_second<10){
- lcd.setCursor(0, 1);
- lcd.print(i_second);
- lcd.setCursor(1, 1);
- lcd.print(" ");
- }else{
- lcd.setCursor(0, 1);
- lcd.print(i_second);
- }
- if(digitalRead(button_12)==HIGH){
- i_second=1+i_second;
- if(i_second==60){
- i_second=0;
- }
-
- }
- if(digitalRead(button_11)==HIGH){
- i_second=i_second-1;
- if(i_second==-1){
- i_second=59;
- }
- }
- if(digitalRead(button_13)==HIGH){
- break;
- }
- delay(100);
- }
- while((flag_RTC%7)==6){
- lcd.setCursor(0, 0);
- lcd.print("week adjust ");
- lcd.setCursor(0, 1);
- lcd.print(i_week);
- if(digitalRead(button_12)==HIGH){
- i_week=1+i_week;
- if(i_week==8){
- i_week=1;
- }
-
- }
- if(digitalRead(button_11)==HIGH){
- i_week=i_week-1;
- if(i_week==0){
- i_week=7;
- }
- }
- if(digitalRead(button_13)==HIGH){
- break;
- }
- delay(100);
- }
- }
- if(digitalRead(button_11)==HIGH){
- rtc.adjustRtc(i_year,i_month,i_day,i_week,i_hour,i_minute,i_second);
- break;
- }
- }
- }
-
- //闹钟调节模式
- void AC_adjust(){
- delay(200);
- int flag_AC=0;
- int S_value=0;
- while(1){
- if(digitalRead(button_12)==HIGH){
- delay(100);
- flag_AC=1+flag_AC;
- }
- if(flag_AC%4==0){
- lcd.setCursor(0, 0);
- lcd.print("AC 1 adjust ");
- lcd.setCursor(0, 1);
- lcd.print(" ");
- }else if(flag_AC%4==1){
- lcd.setCursor(0, 0);
- lcd.print("AC 2 adjust ");
- lcd.setCursor(0, 1);
- lcd.print(" ");
- }else if(flag_AC%4==2){
- lcd.setCursor(0, 0);
- lcd.print("AC 3 adjust ");
- lcd.setCursor(0, 1);
- lcd.print(" ");
- }else{
- lcd.setCursor(0, 0);
- lcd.print("AC 4 adjust ");
- lcd.setCursor(0, 1);
- lcd.print(" ");
- }
- if(digitalRead(button_13)==HIGH){
- delay(200);
- if(flag_AC%4==0){
- S_value=flag_AC%4;
- AC_adjust_value(S_value);
- }else if(flag_AC%4==1){
- S_value=flag_AC%4;
- AC_adjust_value(S_value);
- }else if(flag_AC%4==2){
- S_value=flag_AC%4;
- AC_adjust_value(S_value);
- }else{
- S_value=flag_AC%4;
- AC_adjust_value(S_value);
- }
- }
- if(digitalRead(button_11)==HIGH){
- delay(500);
- break;
- }
-
- }
- }
-
- void AC_adjust_value(int S_value){
- int value;
- value=S_value;
- while(1){
- lcd.setCursor(0, 1);
- lcd.print("hour");
- lcd.setCursor(4, 1);
- lcd.print(" ");
- if(a[value][0]<10){
- lcd.setCursor(5, 1);
- lcd.print(a[value][0]);
- lcd.setCursor(6, 1);
- lcd.print(" ");
- }else{
- lcd.setCursor(5, 1);
- lcd.print(a[value][0]);
- }
- if(digitalRead(button_12)==HIGH){
- delay(200);
- a[value][0]=1+a[value][0];
- if(a[value][0]==24){
- a[value][0]=0;
- }
- }if(digitalRead(button_11)==HIGH){
- delay(200);
- a[value][0]=a[value][0]-1;
- if(a[value][0]==-1){
- a[value][0]=23;
- }
- }
- if(digitalRead(button_13)==HIGH){
- delay(200);
- break;
- }
- }
- while(1){
- lcd.setCursor(0, 1);
- lcd.print("minute");
- lcd.setCursor(6, 1);
- lcd.print(" ");
- if(a[value][1]<10){
- lcd.setCursor(7, 1);
- lcd.print(a[value][1]);
- lcd.setCursor(8, 1);
- lcd.print(" ");
- }else{
- lcd.setCursor(7, 1);
- lcd.print(a[value][1]);
- }
- if(digitalRead(button_12)==HIGH){
- a[value][1]=1+a[value][1];
- if(a[value][1]==60){
- a[value][1]=0;
- }
- }
- if(digitalRead(button_11)==HIGH){
- a[value][1]=a[value][1]-1;
- if(a[value][1]==-1){
- a[value][1]=59;
- }
- }
- if(digitalRead(button_13)==HIGH){
- delay(200);
- break;
- }
- }
- while(1){
- lcd.setCursor(0, 1);
- lcd.print("vaild or not");
- lcd.setCursor(12, 1);
- lcd.print(" ");
- if(a[value][2]==0){
- lcd.setCursor(13, 1);
- lcd.print("F");
- }else{
- lcd.setCursor(13, 1);
- lcd.print("T");
- }
- if(digitalRead(button_12)==HIGH){
- a[value][2]=1-a[value][2];
- delay(100);
- }
- if(digitalRead(button_11)==HIGH){
- a[value][2]=1-a[value][2];
- delay(100);
- }
- if(digitalRead(button_13)==HIGH){
- delay(100);
- break;
- }
- }
- }
-
- void AC_judge(){
- int judge_value;
- for(judge_value =0;judge_value<4;judge_value++){
- if(a[judge_value][2]==1){
- if((a[judge_value][0]==rtc.hour)&&(a[judge_value][1]==rtc.minute)&&(rtc.second==0)){
- sing_song();
- }
- }
- }
- for(judge_value =0;judge_value<4;judge_value++){
- if(b[judge_value][2]==1){
- if((b[judge_value][0]==rtc.hour)&&(b[judge_value][1]==rtc.minute)&&(rtc.second==0)){
- sing_song();
- }
- }
- }
- for(judge_value =0;judge_value<4;judge_value++){
- if(c[judge_value][5]==1){
- if((c[judge_value][0]==rtc.year)&&(c[judge_value][1]==rtc.month)&&(c[judge_value][2]==rtc.day)&&(c[judge_value][3]==rtc.hour)&&(c[judge_value][4]==rtc.minute)&&(rtc.second==0)){
- sing_song();
- }
- }
- }
- }
-
- void sing_song(){
- int sing_song_value=1;
- while(sing_song_value){
- for(int x=0;x<sizeof(tune)/sizeof(int);x++){ //循环音符的次数
- ledcWriteTone(channel, tune[x]);
- delay(400*duration[x]);
- if(digitalRead(button_13)==HIGH){
- delay(200);
- sing_song_value=0;
- x=98;
- }
- }
- delay(1000);//等待5秒后,循环重新开始
- ledcWriteTone(channel, 0);
- }
- }
复制代码
注意:上传代码前需要加载对应的库文件
五、产品外观 友商产品: 图三 通过图三与图四比较,可以发现我们的结构特色: - 易拆解替换存储的药盒
- 长方体结构,便携带(简约型、省空间)
- 可添加格栏,有效分类
六、市场定位 场景: 需要定时吃药的健忘的中老年人(目标客户) 谁会去买单: 中老年人的子女 养老院、医疗机构、药店
|