🔹 プラン:仕組み
1️⃣ Arduino R4 WiFi を作成します ウェブサーバー.
2️⃣ シンプルな ウェブページ(ボタン/スライダー付き) モーターを制御します。
3️⃣ Arduino について ボタンの押下を読み取る を動かします サーボ + ステッピングモーター それに応じて。
🔹 必要なコンポーネント
✅ Arduino R4 WiFi
✅ SG90サーボ
✅ 28BYJ-48 ステッパー + ULN2003 ドライバー
✅ WiFi ネットワーク (ルーターまたはホットスポット)
🔹 ステップ1: モーターをArduinoに接続する

🔸 SG90 サーボ
| サーボ Pin | Arduinoの Pin |
|---|---|
| VCC (赤) | 5V |
| GND (ブラック) | GND |
| 信号(オレンジ) | Pin 6 |
🔸 28BYJ-48 ステッパー (ULN2003 ドライバー経由)
| ULN2003 Pin | Arduinoの Pin |
|---|---|
| IN1 | 8 |
| IN2 | 9 |
| IN3 | 10 |
| IN4 | 11 |
| VCC | 5V |
| GND | GND |
🔹 ステップ 2: Arduino コード (WiFi Web サーバー)
このコードは、 ウェブページ 両方を制御するボタン付き サーボモーターとステッピングモーター.
#include <WiFiS3.h>
#include <Servo.h>
#include <Stepper.h>
const char* ssid = "YOUR_WIFI_NAME"; // Change to your WiFi
const char* password = "YOUR_WIFI_PASS"; // Change to your WiFi password
WiFiServer server(80); // Start web server on port 80
Servo myServo;
const int stepsPerRevolution = 2048;
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);
void setup() {
Serial.begin(115200);
myServo.attach(6);
myStepper.setSpeed(10);
// Connect to WiFi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("Connected to WiFi!");
Serial.println(WiFi.localIP()); // Print IP Address
server.begin(); // Start web server
}
void loop() {
WiFiClient client = server.available();
if (client) {
String request = client.readStringUntil('\r');
client.flush();
if (request.indexOf("/servo_up") != -1) {
myServo.write(180); // Move Servo UP
} else if (request.indexOf("/servo_down") != -1) {
myServo.write(0); // Move Servo DOWN
} else if (request.indexOf("/stepper_left") != -1) {
myStepper.step(-50); // Stepper Left
} else if (request.indexOf("/stepper_right") != -1) {
myStepper.step(50); // Stepper Right
}
// HTML Webpage
client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.println();
client.println("<html><body>");
client.println("<h2>Motor Control</h2>");
client.println("<button onclick=\"fetch('/servo_up')\">Servo Up</button>");
client.println("<button onclick=\"fetch('/servo_down')\">Servo Down</button>");
client.println("<br><br>");
client.println("<button onclick=\"fetch('/stepper_left')\">Stepper Left</button>");
client.println("<button onclick=\"fetch('/stepper_right')\">Stepper Right</button>");
client.println("</body></html>");
client.println();
delay(100);
}
}
🔹 ステップ3: 使い方
1️⃣ コードをアップロードする Arduino R4 WiFi に接続します。
2️⃣ シリアルモニターを開く → あなたの IPアドレス (例えば、 192.168.1.100).
3️⃣ 携帯電話またはPCでウェブブラウザを開いて次の場所に移動します:
👉 http://YOUR_IP_ADDRESS/
4️⃣ ボタンをクリックしてください を移動する サーボとステッパー ワイヤレスで!🎮✨
🔹 次のステップとアップグレード
🔥 スライダーを使用する サーボの角度をスムーズに設定できます。
🔥 ジョイスティックのようなボタンを追加する ステッパー速度制御用。
🔥 より優れたデザインのウェブページをホストする モバイルフレンドリーな UI を備えています。





