LoginSignup
3
2

More than 5 years have passed since last update.

ESP-WROOM-02で振動アクチュエータを二つ駆動してみました

Posted at

(将来的に)Wifiで動くバイブを作りました - Eros DIY Blogと同一の内容です。Qiitaにふさわしくいかがわしい文言を削除しました。

500円〜1000円で入手でき、Wifiがアクセスでき、Arduinoのコードがほぼそのまま動くESP-WROOM-02に振動アクチュエータ使ってみました - Eros DIY Blogで試した振動アクチュエータを二つつないでみました。

作成方法

回路図

パーツ

Arduino ソース

// Copyright 2016 Eros M@ker.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#define VIBES1_PIN 13
#define VIBES2_PIN 16
#define VIBE_WAIT 4166

void setup() {
  pinMode(VIBES1_PIN, OUTPUT);
  pinMode(VIBES2_PIN, OUTPUT);
}

void wait(long us) {
  int msec = us / 1000;
  int usec = us % 1000;
  if (msec > 0) {
    delay(msec);
  }
  if (usec > 0) {
    delayMicroseconds(usec);
  }
}

void loop() {
    long vibration_sec = random(1, 10);
    long cnt = vibration_sec * 1000 * 1000 / (VIBE_WAIT * 2);
    while (--cnt > 0) {
      digitalWrite(VIBES1_PIN, HIGH);
      digitalWrite(VIBES2_PIN, HIGH);
      wait(VIBE_WAIT);
      digitalWrite(VIBES1_PIN, LOW);
      digitalWrite(VIBES2_PIN, LOW);
      wait(VIBE_WAIT);
    }

    delay(random(5, 30) * 1000);
}

完成品

外観写真

右に見える二つの振動アクチュエーターが、緩い振動を行います。

ケースの厚さをミスっていてケースに収まりきらない、固定用のスペーサーのネジ穴を開けるのミスったなど、経験値の低さが出ています。

振動アクチュエータに線だけつないだ状態だとあまり音がしていなかったのですが、線をつないでホットボンドで固定したら、何故か音が大きくなりました。

将来的には

二つの振動アクチュエータを左右別々にランダムに刺激を与えたり、1/fゆらぎとかやってみたいですね。

せっかくWifiの使えるマイコンなのでWifi経由で操作できるようにすれば色々と捗りそうです。

3
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2