MokugyOS
The operating system for USB connectable Mokugyo device.
Install / Use
/learn @ukkz/MokugyOSREADME
mokugyOS
The operating system for USB connectable Mokugyo device.

日本語による解説記事は以下リンクより。(READMEの全てをカバーしています)
【USB木魚】叩くと光りながら般若心経が入力できるUSB接続型木魚を作ってみた【作り方解説 & ソースコード公開】 - xor
Hardware creation
1. Requirements
- Mokugyo
Recommendation: Amazon.co.jp: キクタニ 木魚 3寸 9cm TB-9: 楽器 - USB Standard-A(male) to Standard-A(male) cable
- USB Standard-A(female) to Micro-B(male) short cable
- Mallet (optional)
- Small Zabuton (Japanese cushion, optional)
- Microcontroller: Pro Micro - 5V/16MHz - DEV-12640 - SparkFun Electronics
- But you can choice any other ATmega32u4 based boards as main board, like Arduino Micro, Arduino Leonardo.
- This README explains in case using Pro Micro.
- Accelerometer: Adafruit Triple-Axis Accelerometer - ±2/4/8g @ 14-bit - MMA8451 : ID 2019 : $7.95 : Adafruit Industries, Unique & fun DIY electronics and kits
- Full-colored WS2812B compatible LED chip (5 pieces): Adafruit NeoPixel Digital RGB LED Strip - Black 60 LED [BLACK] : ID 1461 : $99.80 : Adafruit Industries, Unique & fun DIY electronics and kits
- No need to buy Adafruit's LED because a bit expensive. Recommend NeoPixel compatible LED, like フルカラーシリアルLEDモジュール - SWITCH-SCIENCE, NeoPixelフルカラーLEDテープ・5V版各種 – Shigezone Online, etc.
- Only 5 pieces needed.
- LED strip type is BEST, will helps making it simply.
- Microphone ~~(optional)~~: SparkFun Electret Microphone Breakout - BOB-12758 - SparkFun Electronics
- Required from v0.2.

2. Drill a USB hole on Mokugyo

Make a square hole by drill and cutter.

Put large side of USB Standard-A(female) to Micro-B(male) short cable to this hole.
3. Connect sensors and LEDs to microcontroller
Pins assign:
| Sensor's Pin | Pro Micro's Pin | |:--|:--| | MMA8451 VIN | VCC | | MMA8451 GND | GND | | MMA8451 SDA | 2 | | MMA8451 SCL | 3 | | LED strip +5V | VCC | | LED strip GND | GND | | LED strip Din | 10 | | Microphone VCC | VCC | | Microphone GND | GND | | Microphone AUD | A0 |
Note: Current version of mokugyOS does not support microphone listening yet so implementing it is optional.

Do soldering to connect sensors to Pro Micro.

As for NeoPixel LED strip, cut 5 pixels and be careful about signal polarity at soldering (check Din pin's arrow sign direction on the strip).
4. Put sensors&controller unit into Mokugyo

- Stick LED strip on inner side of Mokugyo using double sided tape.
- Connect USB-MicroB connector to controller.
- Push sensors&controller into Mokugyo.

Look the 3-axis sign on MMA8451 and pay attension at placing this sensor.
Z-axis: be parallel with hit direction by mallet. Z+ direction is vertically above.
Y-axis: Y+ direction is facing Mokugyo mouth (groove) from central.
Software Installation
1. Install Arduino IDE on your PC if not yet
2. Install board support library for Pro Micro
Following instructions below:
sparkfun/Arduino_Boards: Board definitions for SparkFun-manufactured AVR, ARM, and ESP-based Arduino boards.

After board installation, please set options like above on Arduino IDE.
DO SELECT "ATmega32U4 (5V, 16 MHz)", not other one "(3.3V, 8 MHz)".
3. Install dependencies
Additional arduino libraries are below.
Show the repositories here but all of them can be installed by arduino IDE built-in library manager.
- FreeRTOS
feilipu/Arduino_FreeRTOS_Library: A FreeRTOS Library for all Arduino AVR Devices (Uno, Leonardo, Mega, etc)- Note: MUST BE USE VERSION OF 10.4.4-2 OR EARLIER!
- ~~NeoPixelBus by Makuna~~ (mokugyOS v0.1 only)
~~Makuna/NeoPixelBus: An Arduino NeoPixel support library supporting a large variety of individually addressable LEDs. Please refer to the Wiki for more details. Please use the gitter channel to ask questions as the GitHub Issues feature is used for bug tracking.~~ - Adafruit NeoPixel Library (mokugyOS v0.2~)
adafruit/Adafruit_NeoPixel: Arduino library for controlling single-wire LED pixels (NeoPixel, WS2812, etc.) - MIDIUSB
arduino-libraries/MIDIUSB: A MIDI library over USB, based on PluggableUSB - Adafruit MMA8451 Library
adafruit/Adafruit_MMA8451_Library: Arduino library for the MMA8451 Accelerometer sensors in the Adafruit shop- No need install Adafruit Unified Sensor Driver.
4. Writing sutra data into EEPROM
ukkz/SutraWriter: EEPROM writer for mokugyOS.
- Connect your Mokugyo to PC with USB cable.
- Clone or ZIP download ukkz/SutraWriter repository.
- Open
SutraWriter.inowith Arduino IDE. - Open Serial Monitor window, and then click upload button to write sketch into Mokugyo.
- SutraWriter runs immediately. Check Serial Monitor to verify EEPROM data like below:

5. Upload mokugyOS
Clone or ZIP download this repository and upload to your Mokugyo.
Configuration
All configurable parameters are placed in Config.h.
How to use
Mode change

Stand up and tilt left or right to change running mode.
Lay down to run the selected mode.
Default mode is "Chanting Keyboard".
| LED color | Mode | |:--|:--| | Blue | Chanting Keyboard | | Yellow | Serial Commander | | Red | MIDI Instrument | | White | Generic Directional Pad | | Orange | Generic Mouse | | Mixed | Game Controller |
About this color variants: Buddhist flag - Wikipedia
Chanting Keyboard Mode

Sends sutra phrase per beat as USB HID keyboard.
Serial Commander Mode

Sends beating and 4-directional tilting command as USB Serial device.
MIDI Instrument Mode

Sends Note-On and Note-Off messages as USB MIDI device.
Generic Directional Pad Mode

Sends beating (Enter key click) and 4-directional tilting (Arrow keys click) as USB HID keyboard.
Generic Mouse Mode

Sends beating (Mouse left click) and 4-directional tilting (Mouse cursor move) as USB HID mouse.
Game Controller Mode

Sends beating (Mouse left click), X-directional tilting (Horizontal mouse cursor move) and Y-directional tilting (W key or S key click) as USB HID keyboard & mouse.
LICENCE
This project is licensed under the MIT License - see the LICENSE.md file for details.
Related Skills
node-connect
347.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
