上海智位机器人股份有限公司 沪ICP备09038501号-4
作品设计:何昊泽 李文涛
模型设计:何昊泽 李文涛
程序设计:李文涛
材料收集:何昊泽
指导教师:魏鹏飞 陈晓雪
一、创作灵感:听力障碍者在户外运动或探险,攀登高山,出外踏青......在这些应用场景下,有时需要一些可以简单判定所处环境范围的设备,有时需要与他人通信,而又有时需要放出紧急求救信号,为什么不把这些功能做在一起呢?经过多次尝试,我们成功将自己的想法与Arduino结合,设计出了多功能户外装置。
二、功能介绍
三、演示视频
四、制作过程
2、固定与装饰
3、腰带与电源
五、硬件清单
六、程序代码
#include <DFString.h>
#include <UNO_Obloq.h>
#include <DFRobot_DHT.h>
#include <DFRobot_Servo.h>
#include <SoftwareSerial.h>
#include <DFRobot_NeoPixel.h>
#include <DFRobot_SSD1306_I2C.h>
// 动态变量
String mind_s_T;
volatile float mind_n_a, mind_n_i;
// 函数声明
void DF_XiaoXi();
void DF_AnNiu();
void DF_XinXiMianBan();
void DF_DuoJi();
void DF_SOS();
void DF_ChuShiHua();
// 静态常量
const chCode chBuf[] = {
{0x6d88,0xe6b688,0xCFFB,{0x00,0x40,0x22,0x48,0x11,0x48,0x11,0x50,0x80,0x40,0x43,0xf8,0x4a,0x08,0x0a,0x08,0x13,0xf8,0x12,0x08,0xe2,0x08,0x23,0xf8,0x22,0x08,0x22,0x08,0x22,0x28,0x02,0x10}},
{0x606f,0xe681af,0xCFA2,{0x01,0x00,0x02,0x00,0x1f,0xf0,0x10,0x10,0x1f,0xf0,0x10,0x10,0x1f,0xf0,0x10,0x10,0x1f,0xf0,0x10,0x10,0x01,0x00,0x08,0x84,0x48,0x92,0x48,0x12,0x87,0xf0,0x00,0x00}},
{0x4fe1,0xe4bfa1,0xD0C5,{0x08,0x40,0x08,0x20,0x0b,0xfe,0x10,0x00,0x10,0x00,0x31,0xfc,0x30,0x00,0x50,0x00,0x91,0xfc,0x10,0x00,0x10,0x00,0x11,0xfc,0x11,0x04,0x11,0x04,0x11,0xfc,0x11,0x04}},
{0x9762,0xe99da2,0xC3E6,{0x00,0x00,0xff,0xfe,0x02,0x00,0x02,0x00,0x04,0x00,0x3f,0xf8,0x24,0x48,0x24,0x48,0x27,0xc8,0x24,0x48,0x24,0x48,0x27,0xc8,0x24,0x48,0x24,0x48,0x3f,0xf8,0x20,0x08}},
{0x677f,0xe69dbf,0xB0E5,{0x10,0x08,0x10,0x1c,0x11,0xe0,0x11,0x00,0xfd,0x00,0x11,0xfc,0x31,0x44,0x39,0x44,0x55,0x44,0x55,0x28,0x91,0x28,0x11,0x10,0x11,0x10,0x12,0x28,0x12,0x44,0x14,0x82}},
{0x5b9e,0xe5ae9e,0xCAB5,{0x02,0x00,0x01,0x00,0x7f,0xfe,0x40,0x02,0x88,0x84,0x04,0x80,0x04,0x80,0x10,0x80,0x08,0x80,0x08,0x80,0xff,0xfe,0x01,0x40,0x02,0x20,0x04,0x10,0x18,0x08,0x60,0x04}},
{0x65f6,0xe697b6,0xCAB1,{0x00,0x08,0x00,0x08,0x7c,0x08,0x44,0x08,0x45,0xfe,0x44,0x08,0x44,0x08,0x7c,0x08,0x44,0x88,0x44,0x48,0x44,0x48,0x44,0x08,0x7c,0x08,0x44,0x08,0x00,0x28,0x00,0x10}},
{0x4eae,0xe4baae,0xC1C1,{0x02,0x00,0x01,0x00,0x7f,0xfc,0x00,0x00,0x1f,0xf0,0x10,0x10,0x1f,0xf0,0x00,0x00,0x7f,0xfe,0x40,0x02,0x8f,0xe4,0x08,0x20,0x08,0x20,0x10,0x22,0x20,0x22,0xc0,0x1e}},
{0x5ea6,0xe5baa6,0xB6C8,{0x01,0x00,0x00,0x80,0x3f,0xfe,0x22,0x20,0x22,0x20,0x3f,0xfc,0x22,0x20,0x22,0x20,0x23,0xe0,0x20,0x00,0x2f,0xf0,0x24,0x10,0x42,0x20,0x41,0xc0,0x86,0x30,0x38,0x0e}},
{0x6e29,0xe6b8a9,0xCEC2,{0x00,0x00,0x23,0xf8,0x12,0x08,0x12,0x08,0x83,0xf8,0x42,0x08,0x42,0x08,0x13,0xf8,0x10,0x00,0x27,0xfc,0xe4,0xa4,0x24,0xa4,0x24,0xa4,0x24,0xa4,0x2f,0xfe,0x00,0x00}},
{0x2103,0xe28483,0xA1E6,{0x60,0x00,0x91,0xf4,0x96,0x0c,0x6c,0x04,0x08,0x04,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x08,0x00,0x0c,0x04,0x06,0x08,0x01,0xf0,0x00,0x00}},
{0x6e7f,0xe6b9bf,0xCAAA,{0x00,0x00,0x27,0xf8,0x14,0x08,0x14,0x08,0x87,0xf8,0x44,0x08,0x44,0x08,0x17,0xf8,0x11,0x20,0x21,0x20,0xe9,0x24,0x25,0x28,0x23,0x30,0x21,0x20,0x2f,0xfe,0x00,0x00}}
};
const String topics[5] = {"xm/1","","","",""};
// 创建对象
DFRobot_SSD1306_I2C oled12864;
DFRobot_NeoPixel neoPixel_4;
DFRobot_DHT dht11_A3;
Servo servo_9;
UNO_Obloq olq;
SoftwareSerial softSerial(2, 3);
// 主程序开始
void setup() {
oled12864.setChCode(chBuf);
dht11_A3.begin(A3, DHT11);
servo_9.attach(9);
DF_ChuShiHua();
}
void loop() {
if ((digitalRead(5)==1)) {
DF_AnNiu();
}
if (((((int)mind_n_a) % ((int)3))==0)) {
DF_XinXiMianBan();
}
else if (((((int)mind_n_a) % ((int)3))==1)) {
DF_XiaoXi();
}
else if ((((((int)mind_n_a) % ((int)3))==2) && (analogRead(A2)<8))) {
DF_SOS();
}
else {
neoPixel_4.setRangeColor(0, 4, 0xFFFF99);
neoPixel_4.setBrightness((map(analogRead(A2), 0, 1023, 0, 255)));
}
if (((((int)mind_n_a) % ((int)3))==2)) {
oled12864.setCursorLine(1);
oled12864.printLine("SOS");
}
DF_DuoJi();
}
// 自定义函数
void DF_XiaoXi() {
oled12864.setCursorLine(1);
oled12864.printLine("消息");
neoPixel_4.setRangeColor(0, 4, 0x6600CC);
neoPixel_4.setBrightness(6);
mind_s_T = olq.getMessage(olq.topic_0);
for (int index = 0; index < 1; index++) {
digitalWrite(10, HIGH);
delay(40);
digitalWrite(10, LOW);
for (int index = 0; index < 100; index++) {
oled12864.setCursorLine(2);
oled12864.printLine(mind_s_T);
delay(10);
}
}
}
void DF_AnNiu() {
delay(500);
mind_n_a += 1;
oled12864.fillScreen(0);
digitalWrite(10, HIGH);
delay(40);
digitalWrite(10, LOW);
}
void DF_XinXiMianBan() {
neoPixel_4.setRangeColor(0, 4, 0xFFFF99);
neoPixel_4.setBrightness((map(analogRead(A2), 0, 1023, 0, 255)));
oled12864.setCursorLine(1);
oled12864.printLine("信息面板");
oled12864.setCursorLine(2);
oled12864.printLine((String("实时亮度") + String(analogRead(A2))));
oled12864.setCursorLine(3);
oled12864.printLine((String((String("温度 ") + String((dfstring.substring((String(dht11_A3.getTemperature())),0,1,0,2))))) + String("℃")));
oled12864.setCursorLine(4);
oled12864.printLine((String((String("湿度 ") + String((dfstring.substring((String(dht11_A3.getHumidity())),0,1,0,2))))) + String("%rh")));
}
void DF_DuoJi() {
if ((digitalRead(8)==1)) {
mind_n_i += 1;
delay(1500);
if (((((int)mind_n_i) % ((int)2))==1)) {
servo_9.angle(abs(175));
oled12864.setRotaion(eROTATION_0);
}
else {
servo_9.angle(abs(85));
oled12864.setRotaion(eROTATION_180);
}
}
}
void DF_SOS() {
neoPixel_4.setRangeColor(0, 4, 0xFF0000);
while (!(!(((((int)mind_n_a) % ((int)3))==2) && (analogRead(A2)<8)))) {
for (int index = 0; index < 3; index++) {
neoPixel_4.setBrightness(255);
digitalWrite(10, HIGH);
delay(80);
neoPixel_4.setBrightness(0);
digitalWrite(10, LOW);
delay(80);
}
for (int index = 0; index < 3; index++) {
neoPixel_4.setBrightness(255);
digitalWrite(10, HIGH);
delay(700);
neoPixel_4.setBrightness(0);
digitalWrite(10, LOW);
delay(700);
}
for (int index = 0; index < 3; index++) {
neoPixel_4.setBrightness(255);
digitalWrite(10, HIGH);
delay(80);
neoPixel_4.setBrightness(0);
digitalWrite(10, LOW);
delay(80);
}
delay(2000);
}
}
void DF_ChuShiHua() {
softSerial.begin(9600);
olq.startConnect(&softSerial, "zhangT", "12345678", "siot", "dfrobot", topics, "192.168.0.106", 1883);
servo_9.angle(abs(86));
oled12864.begin(0x3c);
oled12864.fillScreen(0);
neoPixel_4.begin(4, 5);
neoPixel_4.setBrightness(0);
mind_n_a = 0;
mind_n_i = 0;
}