智能配对墨镜:Arduino 101 + tinyTILE BLE 实现眼神交流信号
元器件清单
| 元器件 | 数量 | 备注 |
|---|---|---|
| Intel tinyTILE (或其他 BLE 模块) | 2 | 主从各一,主控+BLE |
| Arduino 101 | 2 | 可选,开发调试用 |
| Adafruit 液晶光阀 (LCD 可控遮光面板) | 2 | 镜片核心部件 |
| 100mAh 锂电池 | 2 | 每副墨镜一块 |
| JST-PH 2Pin SMT 直角连接器 | 4 | 电池/开关连接 |
| JST-PH 电池延长线 | 2 | |
| 滑动开关 | 2 | 电源开关 |
| 10kΩ 电阻 | 3 | 上拉/下拉 |
| 12mm 轻触开关 | 1 | 主控侧触发按钮 |
| LED (通用) | 2 | 仅开发调试用 |
| 面包板 | 1 | 仅开发调试用 |
| 跳线 | 若干 | 仅开发调试用 |
所需工具
- 3D 打印机 (打印镜框)
- 电烙铁 (焊接)
所需软件
- Arduino IDE
- Arduino Web Editor
项目理念
不使用手机 APP,而是通过蓝牙低功耗 (BLE) 直接在两副墨镜间建立连接。当一方按下按钮表达好感时,双方墨镜镜片同时从不透明(墨镜状态)变为透明,实现"眼神接触"的物理隐喻。主控端作为 BLE Central,从机端作为 Peripheral,按钮触发中央写入特征值,外设响应改变镜片状态。
开发阶段
- 先用两块 Arduino 101 + LED 验证 BLE 通信逻辑
- 外设端参考
CurieBLE → Peripheral → LED例程,注意将 HIGH/LOW 取反 (因 LCD 光阀逻辑相反) - 中央端参考
CurieBLE → Central → LEDControl,添加 LCD 控制代码 - 迁移到 tinyTILE (Arduino 101 迷你版,同款 Curie 芯片),替换 LED 为 LCD 光阀
3D 打印镜框
基于 Adafruit 教程的镜框模型重新设计 (SolidWorks),提供两款造型:
- Heart (心形):主控端,佩戴者主动发起
- Universe (宇宙):从机端,等待被唤醒
模型文件见项目附件,可根据面部尺寸微调。作者建议使用水溶性支撑材料或光固化打印机以减少后处理。
组装焊接
参考 Adafruit 原教程的布线、焊接、安装指南。关键点:
- 导线长度预留准确,避免过长/过短
- tinyTILE 体积小,焊接需耐心
- LCD 光阀驱动需施加交流电压 (代码中通过 PWM 模拟)
- 电池、开关、充电接口布局紧凑
工作演示
- 上电后:两副墨镜均为深色 (施加电压,LCD 光阀不透明)
- 主控端按下按钮:主控镜片变透明 (切断电压),同时通过 BLE 通知从机
- 从机收到指令:镜片同步变透明
- 释放按钮:双方恢复墨镜状态
- 有效距离:室内测试约 15 步 (BLE 典型范围)
Heart (主控) :"I like your sophisticated mind <3"
Universe (从机) :"I see you. Let's talk."
核心代码 (中央端按钮控制)
/*
* Copyright (c) 2016 Intel Corporation. All rights reserved.
* BLE Central - LCD 控制 (基于 CurieBLE LEDControl 例程修改)
*/
#include
// 按钮引脚
const int buttonPin = 3;
int oldButtonState = LOW;
// LCD 控制引脚 (中央端)
const int ledPin = 5;
void setup() {
Serial.begin(9600);
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
BLE.begin();
Serial.println("BLE Central - LCD control");
// 扫描指定 UUID 的外设
BLE.scanForUuid("19b10000-e8f2-537e-4f6c-d104768a1214");
}
void loop() {
BLEDevice peripheral = BLE.available();
if (peripheral) {
// 发现外设
Serial.print("Found ");
Serial.print(peripheral.address());
Serial.print(" '");
Serial.print(peripheral.localName());
Serial.print("' ");
Serial.println(peripheral.advertisedServiceUuid());
BLE.stopScan();
controlLed(peripheral);
// 断开后重新扫描
BLE.scanForUuid("19b10000-e8f2-537e-4f6c-d104768a1214");
}
}
void controlLed(BLEDevice peripheral) {
Serial.println("Connecting ...");
if (!peripheral.connect()) {
Serial.println("Failed to connect!");
return;
}
Serial.println("Connected");
Serial.println("Discovering attributes ...");
if (!peripheral.discoverAttributes()) {
Serial.println("Attribute discovery failed!");
peripheral.disconnect();
return;
}
Serial.println("Attributes discovered");
// 获取 LED 特征值 (实际控制 LCD 光阀)
BLECharacteristic ledCharacteristic = peripheral.characteristic("19b10001-e8f2-537e-4f6c-d104768a1214");
if (!ledCharacteristic || !ledCharacteristic.canWrite()) {
Serial.println("Peripheral does not have writable LCD characteristic!");
peripheral.disconnect();
return;
}
while (peripheral.connected()) {
int buttonState = digitalRead(buttonPin);
if (oldButtonState != buttonState) {
oldButtonState = buttonState;
if (buttonState) { // 按下
Serial.println("button pressed");
ledCharacteristic.writeByte(0x01); // 发送 0x01 → 透明
digitalWrite(ledPin, LOW); // 本地 LCD 也透明
} else { // 释放
Serial.println("button released");
ledCharacteristic.writeByte(0x00); // 发送 0x00 → 不透明
digitalWrite(ledPin, HIGH); // 本地 LCD 恢复墨镜
}
}
}
Serial.println("Peripheral disconnected");
}
外设端代码要点
参考 CurieBLE → Peripheral → LED 例程,修改:
- UUID 保持一致:Service `19b10000-...`,Characteristic `19b10001-...`
- 特征值可写、可读
- 收到 `0x01` → LCD 透明 (输出 LOW);收到 `0x00` → LCD 不透明 (输出 HIGH)
- 引脚分配:Central 用 D3(按钮)、D5(LCD);Peripheral 用 D6(LCD)
原理图
未来展望
- 替代按钮:手势识别 (IMU)、点头检测、心率同步
- 多设备群组配对:派对破冰游戏
- 集成骨传导耳机:配对后自动建立语音通道
- 迁移至 nRF52840 / ESP32-C3 等现代 BLE SoC
制造工艺
- 太阳镜:设计、材料与护眼标准
- 电池:从伏打电堆到现代锂电池的演进史
- UnifiedWater v1 — 基于 Arduino MKR GSM 1400 的完整水质监测套件
- Arduino 项目优化供电方案:从按键开关到电池监测与数据记录
- 3D 打印钢铁侠头盔与反应堆:Arduino 控制舵机与 NeoPixel 全攻略
- 便携式 GSM 投票箱:基于 Hologram + IFTTT 实现云端数据采集
- Arduino 101 BLE + Blynk:DIY 蓝牙遥控履带坦克车
- DIY 打地鼠街机游戏(按键版)——Arduino Mega 2560 实现
- 现代复古点唱机:Raspberry Pi + Arduino NeoPixel 声控灯光音乐播放器
- 汽车蓄电池核心技术:原理、分类、规格与维护全攻略
- 发电机(交流发电机)检测全攻略:万用表、螺丝刀、断电法实测指南
- 发电机故障的7大信号:别等趴窝才后悔