2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

DDR(フットコントローラ)をArduino Microをとおして認識させるときのメモ

Posted at

はじめに

本記事はDDR(Dance Dance Revolution)のフットコントローラをArduino Microを介してパソコンに認識させるための改造メモです。

Amazonでは下記のようなDDRのパチモンが、よくわからないメーカーから販売されています。
USBでPCと接続・認識しますが、Mac catalinaでいまいち認識しなかったので、仕組みを理解する・分解を楽しむために改造してみました。

有料ソフトでこういったコントローラを認識するソフトがあるので、改造が手間という場合はそちらを使った方が良さそうです。

image.png

必要なもの

  • フットコントローラ
  • Arduino Micro (もしくはArduino Leonardo、Arduino Due)
     → HID機能をつかって入力をキーボードのボタンに割り当てるためHID機能がついているボードを使います。

分解

基板部分を分解すると、下記のようになっていました。
フットコントローラ部分の接続は薄いフィルムとなっていて、基板部分と接触することでつながっています。
真ん中の少し太い線がGNDで、それ以外がフットコントローラのそれぞれの入力ピンとなっています。

配線.jpg

そこから配線を適当に伸ばします。
そしてこれらをマイコンにつなぎます。
GNDはGND、入力ピンはデジタルピンに繋ぎます。
これで回路の準備は終わりです。

footcontroller10.jpg

プログラム

Githubにも一応あげておきます。
まずはどの入力ピンがどのボタンに接続されているか確かめます。
下記のプログラムのピン番号は任意です。
ボタンとピンの割り当てがわかればメモしておきましょう。

# define SERIAL Serial

void setup() {
  SERIAL.begin(115200);
  pinMode(3, INPUT_PULLUP);
  pinMode(4, INPUT_PULLUP);
  pinMode(5, INPUT_PULLUP);
  pinMode(6, INPUT_PULLUP);
  pinMode(7, INPUT_PULLUP);
  pinMode(8, INPUT_PULLUP);
  pinMode(9, INPUT_PULLUP);
  pinMode(10, INPUT_PULLUP);
  pinMode(14, INPUT_PULLUP);
  pinMode(15, INPUT_PULLUP);
  pinMode(16, INPUT_PULLUP);
}

void loop() {
  SERIAL.println("Pin 3 is : ");
  SERIAL.println(digitalRead(3));
  SERIAL.println("Pin 4 is : ");
  SERIAL.println(digitalRead(4));
  SERIAL.println("Pin 5 is : ");
  SERIAL.println(digitalRead(5));
  SERIAL.println("Pin 6 is : ");
  SERIAL.println(digitalRead(6));
  SERIAL.println("Pin 7 is : ");
  SERIAL.println(digitalRead(7));
  SERIAL.println("Pin 8 is : ");
  SERIAL.println(digitalRead(8));
  SERIAL.println("Pin 9 is : ");
  SERIAL.println(digitalRead(9));
  SERIAL.println("Pin 10 is : ");
  SERIAL.println(digitalRead(10));
  SERIAL.println("Pin 11 is : ");
  SERIAL.println(digitalRead(11));
  SERIAL.println("Pin 12 is : ");
  SERIAL.println(digitalRead(12));
  SERIAL.println("Pin 13 is : ");
  SERIAL.println(digitalRead(13));

  delay(1000);
}

Arduino Microに書き込むプログラムは下記の通りです。
フットコントローラの入力をキーボードの入力に置き換えています。

# include <Arduino.h>
# include "Keyboard.h"
# define SERIAL Serial

const int inputPin = 3;
bool currentState = HIGH;
bool beforeState = HIGH;

void setup() {
  SERIAL.begin(115200);
  pinMode(3, INPUT_PULLUP);
  pinMode(4, INPUT_PULLUP);
  pinMode(5, INPUT_PULLUP);
  pinMode(6, INPUT_PULLUP);
  pinMode(7, INPUT_PULLUP);
  pinMode(8, INPUT_PULLUP);
  pinMode(9, INPUT_PULLUP);
  pinMode(10, INPUT_PULLUP);
  pinMode(14, INPUT_PULLUP);
  pinMode(15, INPUT_PULLUP);
  pinMode(16, INPUT_PULLUP);
  Keyboard.begin();
}

void loop() {
  int pinNum[11] = {3, 4, 5, 6, 7, 8, 9, 10, 14, 15, 16};
  #下記は文字コード(ASCIIコード)
  unsigned char s[11] = {0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70, 0x71};

  for(int i; i<11; i++){
    if ( digitalRead(pinNum[i]) == 0){
        //digitalWrite(ledPin, HIGH);
        SerialUSB.println("Push!");
        #ボタンがおされたときに文字を入力
        Keyboard.press( s[i] );
    } else {
        //digitalWrite(ledPin, LOW);
        SerialUSB.println("Release!");
        #ボタンがおされなくなったら文字入力を終了
        Keyboard.release( s[i] );
    }
  }
  delay(500);
}

本当に雑な所感

Arduino MicroやLeonardo、 DueのHID機能をつかいこなすと面白いことができそう。

2
1
0

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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?