# STEPMOTOR モジュール {docsify-ignore-all}
***
:memo:**[概要](#概要)** :octocat:**[サンプルコード](#サンプルコード)** :electric_plug:**[回路図](#回路図)** 🛒**[購入リンク](https://www.aliexpress.com/store/product/M5Stack-New-Arrival-Stepmotor-Module-for-Arduino-ESP32-GRBL-12C-Step-Motor-MEGA328P-similar-as-12V/3226069_32889109142.html?spm=2114.12010612.8148356.17.50511b9b5ViNuz)**
## 概要
**STEPMOTOR**モジュールはATmega328Pを内蔵しており、GRBLファームウェアによってモータをコントロールすることが可能です。M5StackのCoreとの通信にはI2Cを利用しています。I2Cアドレスは**0x70**です。
## 特徴
- 電源入力 9-24V
- 3-Way STEPMOTOR(X, Y, Z)
- リチウムバッテリー用インターフェース内蔵
## パッケージ内容
- 1x STEPMOTOR モジュール
- 1x 12V 電源 (オプション)
- 1x 5V ファンモジュール (オプション)
## アプリケーション
- 自作3Dプリンタ
- シンプルロボットアーム
## 関連リンク
- **[公式ビデオ](https://www.youtube.com/channel/UCozgFVglWYQXbvTmGyS739w)**
- **[フォーラム](http://forum.m5stack.com/)**
- **[モジュール内のMEGA328ファームウェア](https://github.com/m5stack/stepmotor_module/tree/master/Firmware%20for%20stepmotor%20module/GRBL-Arduino-Library)**
## サンプルコード
### 1. Arduino IDE
*以下のコードは不完全です(説明のためだけに). 完全なコードが必要な場合は、ここをクリックしてください[サンプルコード](https://github.com/m5stack/stepmotor_module/tree/master/Example/Arduino)。*
```adrduino
/*
If Button A was pressed,
stepmotor will rotate back and forth at a time
*/
#include
#include
#define STEPMOTOR_I2C_ADDR 0x70
// initialization
M5.begin();
Wire.begin();
// Controlling Protocol:
// G XYZ F
SendCommand(STEPMOTOR_I2C_ADDR, "G1 X20Y20Z20 F500");
SendCommand(STEPMOTOR_I2C_ADDR, "G1 X0Y0Z0 F400");
// Get Data from Module.
Wire.requestFrom(STEPMOTOR_I2C_ADDR, 1);
if (Wire.available() > 0) {
int u = Wire.read();
if (u != 0) Serial.write(u);
}
// Send Data to Module.
while (Serial.available() > 0) {
int inByte = Serial.read();
SendByte(STEPMOTOR_I2C_ADDR, inByte);
}
```
### 2. UIFlow
*特定のルーチンをクリックしてください[ルーチン](https://github.com/m5stack/M5-ProductExampleCodes/blob/master/Module/STEPMOTOR/UIFlow)。*
## 回路図
