惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

G
Google Developers Blog
Cisco Talos Blog
Cisco Talos Blog
Y
Y Combinator Blog
罗磊的独立博客
Stack Overflow Blog
Stack Overflow Blog
MongoDB | Blog
MongoDB | Blog
GbyAI
GbyAI
The GitHub Blog
The GitHub Blog
S
SegmentFault 最新的问题
J
Java Code Geeks
C
CXSECURITY Database RSS Feed - CXSecurity.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
博客园 - 聂微东
B
Blog RSS Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
P
Privacy & Cybersecurity Law Blog
L
LangChain Blog
L
LINUX DO - 热门话题
Hugging Face - Blog
Hugging Face - Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
P
Privacy International News Feed
F
Full Disclosure
S
Schneier on Security
T
Tenable Blog
量子位
NISL@THU
NISL@THU
Latest news
Latest news
V
Visual Studio Blog
C
Check Point Blog
aimingoo的专栏
aimingoo的专栏
博客园_首页
K
Kaspersky official blog
L
Lohrmann on Cybersecurity
美团技术团队
P
Proofpoint News Feed
P
Palo Alto Networks Blog
Spread Privacy
Spread Privacy
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
人人都是产品经理
人人都是产品经理
The Hacker News
The Hacker News
AWS News Blog
AWS News Blog
S
Securelist
The Register - Security
The Register - Security
G
GRAHAM CLULEY
Project Zero
Project Zero
T
The Blog of Author Tim Ferriss
Recent Announcements
Recent Announcements
Engineering at Meta
Engineering at Meta
C
Cisco Blogs

博客园 - 陈大欠

andrej karpathy skills 从 Harness Engineering 到 superpowers 从 Harness Engineering 到 OpenSpec 从 Harness Engineering 到 Trellis Harness Engineering copilot-api:让 ClaudeCode 接入 Github Copilot Claude Code Hooks 配置说明 Scoop MagicCenterHub Windows Terminal & PowerShell 玩转 Visual Studio 外部工具 WCF API 语义搜索工具 Step Builder:让对象构建有顺序、有边界、有校验 基于 Attribute 的 AOP 字段校验 浅析 .NET 响应式编程 IObservable与ReactiveX Cron表达式简明教程 正则表达式拾遗 快速批量升级 NugetPackage 版本 C# IEquatable和IEqualityComparer 最佳实践 使用XDT提高开发效率 如何保证XML正确性 分析 Dump 入门简明教程 Git commit emoji 对照表 ELK Stack 笔记 HTML5/CSS3(PrefixFree.js) 3D文字特效 Jquery实现图片上下一张 js css 构建滚动边框 使用jquery构建Metro style 返回顶部 使用js实现移动设备访问跳转到指定目录 从一幅图中了解开源世界 Jquery ajax 学习笔记 工欲善其事必先利其器系列之:在VS里面折叠js代码
Claude-LED
陈大欠 · 2026-07-18 · via 博客园 - 陈大欠

Claude-LED-LUCKEY 🚦

aiLED

English

Arduino
BLE
Python
Windows
License
GitHub Stars

ESP32C3 蓝牙 BLE 状态指示灯,用于 Claude Code 工作状态的物理提醒。

硬件清单

组件 型号/规格
开发板 ESP32C3-Super-Mini
LED 电路板 三色 LED(共阴极,红/黄/绿)
蜂鸣器 无源蜂鸣器模块(3线制:VCC、IO、GND)

接线定义

组件 引脚 ESP32C3 GPIO 板子位置
LED 红 R GPIO5 右侧第 1 个
LED 黄 Y GPIO6 右侧第 2 个
LED 绿 G GPIO7 右侧第 3 个
LED 地 GND GND 左侧第 2 个
蜂鸣器正 + 3V3 左侧第 3 个
蜂鸣器 IO IO GPIO4 左侧第 4 个
蜂鸣器负 - GND 左侧第 2 个

注意:GPIO8 是板载蓝灯(右侧第 4 个),不要使用。

image

LED 亮度配置

固件中定义了三种颜色的最大亮度常量(0-255),可按需调整:

#define BRIGHTNESS_RED    255
#define BRIGHTNESS_YELLOW 255
#define BRIGHTNESS_GREEN  192

修改后重新烧录固件即可全局生效。

灯效模式(共 20 种)

模式 名称 说明
0 全灭 所有 LED 熄灭
1 三灯同频闪烁 红黄绿同时闪烁,500ms 周期
2 绿灯闪烁 绿灯闪烁,500ms 周期
3 红灯闪烁 红灯闪烁,500ms 周期
4 黄灯闪烁 黄灯闪烁,500ms 周期
5 绿灯常亮 绿灯持续点亮
6 红灯常亮 红灯持续点亮
7 黄灯常亮 黄灯持续点亮
8 三灯常亮 红黄绿同时点亮
9 警车交替快闪 红绿交替 300ms + 黄灯独立快闪 150ms
10 心跳双闪 80ms 亮 → 100ms 灭 → 80ms 亮 → 600ms 灭
11 SOS 摩尔斯求救码 三短三长三短
12 三色轮转呼吸灯 红绿反向渐变 + 黄灯 120° 相位偏移
13 萤火虫混沌呼吸 三灯独立正弦波,周期不同产生非对称律动
14 心电波模拟 红灯 ECG 波形,绿灯 QRS 峰暴闪,黄灯 P/T 波柔和发光
15 三相正弦追逐 绿 sin、红 cos、黄 sin+120°,3s 周期
16 急救爆闪追击 绿 → 黄 → 红各闪 3 下,80ms 亮/80ms 灭
17 太极呼吸 红绿 sin³ 对立消长,黄灯独立 120° 相位偏移
18 HELLO 摩尔斯码 持续广播 HELLO 摩尔斯码
19 雷达扫描与锁定 3s 绿灯正弦扫描 + 黄灯回波 → 1s 红灯锁定闪动 → 0.5s 三灯全亮

蓝牙通信

  • 设备名:Claude-LED-LUCKEY
  • 服务 UUID:f4b7e3a1-5c6d-4e8f-9a2b-1c3d5e7f9a0b
  • 特征值 UUID:8c9d4e2f-1a3b-4c5d-6e7f-8a9b0c1d2e3f
  • 写入方式:Write Without Response
  • 数据格式:UTF-8 字符串

支持的命令

命令格式

mode[,buzzer_param]
  • mode:模式编号(0-19)或名称
  • buzzer_param:蜂鸣器参数
    • 0 = 不响
    • 1 = 短响一声(80ms,2000Hz,主板自检音)
    • 2 = 短响两声(2000Hz + 1000Hz,各 80ms,不同声调)
    • 3 = 高频短响(200ms,4000Hz)

示例:

  • "alarm,1" → 红灯常亮 + 短响一声
  • "alarm,2" → 红灯常亮 + 短响两声(不同声调)
  • "alarm,3" → 红灯常亮 + 高频提示音
  • "alarm,0" → 红灯常亮 + 不响
  • "alarm" → 红灯常亮 + 不响
  • "2" → 模式 2(绿灯闪烁),蜂鸣器不响

数字命令(0-19)

直接发送模式编号,如 "0""17"

名称命令

命令 等效模式
off / close / idle 0
thinking / think 2
busy / executing 7
success / ok / done 5
error / failed 3
alarm / permission 6
green / blink 2
taichi / running / run 17
bothoff 0
bothflash 1
greenflash 2
redflash 3
yellowflash 4
greenon 5
redon 6
yellowon 7
bothon 8
police 9
heartbeat 10
sos 11
breathing 12
firefly 13
ecg 14
phasechase / chase 15
strobe / strobechase 16
hello / hellomorse 18
radar 19
castle / sky 彩蛋:播放天空之城短版(~2.5秒)
castle,1 / sky,1 彩蛋:播放天空之城完整版(~46秒)

使用方法

1. 烧录固件

用 Arduino IDE 打开 firmware/claude-led/claude-led.ino,选择 ESP32C3 开发板,烧录。

2. 测试灯效

# 自动测试全部灯效(每种 3 秒)
python scripts/test-all-effects.py

# 手动测试单个灯效
python scripts/send-hook.py 17        # 太极呼吸
python scripts/send-hook.py taichi    # 同上
python scripts/send-hook.py alarm 1   # 红灯常亮 + 短响一声
python scripts/send-hook.py alarm 2   # 红灯常亮 + 短响两声(不同声调)
python scripts/send-hook.py alarm 0   # 红灯常亮 + 不响

3. Claude Code 集成

~/.claude/settings.json 中添加 hooks:

{
  "hooks": {
    "SessionStart": [
      {
        "matcher": ".*",
        "hooks": [
          {
            "type": "command",
            "command": "python \"D:\\path\\to\\send-hook.py\" 17",
            "timeout": 5000
          }
        ]
      }
    ],
    "PreToolUse": [
      {
        "matcher": ".*",
        "hooks": [
          {
            "type": "command",
            "command": "python \"D:\\path\\to\\send-hook.py\" 2",
            "timeout": 5000
          }
        ]
      }
    ],
    "PermissionRequest": [
      {
        "matcher": ".*",
        "hooks": [
          {
            "type": "command",
            "command": "python \"D:\\path\\to\\send-hook.py\" 4 1",
            "timeout": 5000
          }
        ]
      }
    ]
  }
}

Claude Code 事件与灯效映射

Hook 事件 参数 灯效 蜂鸣器
SessionStart 18 HELLO 摩尔斯码 不响
UserPromptSubmit 2 绿灯闪烁 不响
PreToolUse 2 绿灯闪烁 不响
PostToolUseFailure 3 红灯闪烁 不响
PermissionRequest 4 1 黄灯闪烁 短响一声
Stop 5 绿灯常亮 不响
SessionEnd 17 太极呼吸 不响

首次通电默认灯效为 18(HELLO 摩尔斯码),同时播放天空之城前奏短音作为启动提示。5 分钟无操作后自动关闭。

彩蛋:天空之城

开机自动播放天空之城前奏短音(~2.5 秒)。也可通过命令手动触发:

python scripts/send-hook.py castle      # 短版 (~2.5秒)
python scripts/send-hook.py castle,1    # 完整版 (~46秒)
python scripts/send-hook.py sky         # 同 castle

播放中再次发送 castle 可停止播放。旋律数据由 8051 版本移植而来。

依赖

  • Arduino IDE + ESP32 开发板支持包
  • Python 3.8+
  • bleak(Python BLE 库):pip install bleak

Contributors

Star History

Star History Chart