ドラムをトリガーで映像とかが変化するやつ作りたい（1）

#ドラム部分
##買い物![IMG_9801.JPG](https://qiita-image-store.s3.amazonaws.com/0/13771/8ffc7b9a-daa7-d330-23e0-c23c546af116.jpeg)
>ゴム板3枚、ドラムスティック

これバシバシ叩くと音がなるイメージ
ドラマーじゃないから楽器屋は恥ずかしい><

##圧電素子
ArduinoでKnock!!
プログラムがブラウザでできるようになっとる
[参考](https://www.arduino.cc/en/Tutorial/Knock)
![IMG_6451.JPG](https://qiita-image-store.s3.amazonaws.com/0/13771/f2bc8717-2345-55e6-5277-580075c313f4.jpeg)
そして、グルーガン攻め

##コード
```c:Piezoelectric.c
// these constants won't change:
const int ledPin = 13;      // led connected to digital pin 13
const int knockSensor1 = A0; // the piezo is connected to analog pin 0
const int threshold1 = 10; // threshold value to decide when the detected sound is a knock or not
const int knockSensor2 = A2; // the piezo is connected to analog pin 0
const int threshold2 = 10; // threshold value to decide when the detected sound is a knock or not
const int knockSensor3 = A4; // the piezo is connected to analog pin 0
const int threshold3 = 10; // threshold value to decide when the detected sound is a knock or not

#define BEATTIME 100 //音を出している時間(msec)
#define SPEAKER 12 //スピーカーの出力ピン番号 

// these variables will change:
int sensorReading1 = 0;      // variable to store the value read from the sensor pin
int sensorReading2 = 0;      // variable to store the value read from the sensor pin
int sensorReading3 = 0;      // variable to store the value read from the sensor pin

int ledState = LOW;         // variable used to store the last LED status, to toggle the light

void setup() {
  pinMode(ledPin, OUTPUT); // declare the ledPin as as OUTPUT
  Serial.begin(9600);       // use the serial port
}

void loop() {
  // read the sensor and store it in the variable sensorReading:
  sensorReading1 = analogRead(knockSensor1);
  sensorReading2 = analogRead(knockSensor2);
  sensorReading3 = analogRead(knockSensor3);

  // if the sensor reading is greater than the threshold:
  if (sensorReading1 >= threshold1) {
    // toggle the status of the ledPin:
    ledState = !ledState;
    // update the LED pin itself:
    digitalWrite(ledPin, ledState);
    // send the string "Knock!" back to the computer, followed by newline
    Serial.println("Knock!");
    tone(SPEAKER,330,BEATTIME) ; // ミ
  }
  
  // if the sensor reading is greater than the threshold:
  if (sensorReading2 >= threshold2) {
    // toggle the status of the ledPin:
    ledState = !ledState;
    // update the LED pin itself:
    digitalWrite(ledPin, ledState);
    // send the string "Knock!" back to the computer, followed by newline
    Serial.println("Knock!");
    tone(SPEAKER,300,BEATTIME) ; // ミ
  }
  
  // if the sensor reading is greater than the threshold:
  if (sensorReading3 >= threshold3) {
    // toggle the status of the ledPin:
    ledState = !ledState;
    // update the LED pin itself:
    digitalWrite(ledPin, ledState);
    // send the string "Knock!" back to the computer, followed by newline
    Serial.println("Knock!");
    tone(SPEAKER,100,BEATTIME) ; // ミ
  }
  
  delay(40);  // delay to avoid overloading the serial port buffer
  
  Serial.println(sensorReading3);
  //Serial.println(sensorReading2);
}


```

##こんな感じ
<blockquote class="twitter-video" data-lang="ja"><p lang="ja" dir="ltr">久々にArduino<a href="https://twitter.com/hashtag/Arduino?src=hash">#Arduino</a> <a href="https://twitter.com/hashtag/%E5%9C%A7%E9%9B%BB%E7%B4%A0%E5%AD%90?src=hash">#圧電素子</a> <a href="https://t.co/lWXvb8UNqK">pic.twitter.com/lWXvb8UNqK</a></p>&mdash; いまうじ (@imauji) <a href="https://twitter.com/imauji/status/874262707083419649">2017年6月12日</a></blockquote>
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

##残りの予定
- MIDI化　hairless
- アプリかなにかでアサインした音出す
- MIDI信号を映像側にも送る
- 精度の向上