1
0

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 5 years have passed since last update.

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

Last updated at Posted at 2017-06-12

#ドラム部分
##買い物IMG_9801.JPG

ゴム板3枚、ドラムスティック

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

##圧電素子
ArduinoでKnock!!
プログラムがブラウザでできるようになっとる
参考
IMG_6451.JPG
そして、グルーガン攻め

##コード

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);
}


##こんな感じ

久々にArduino#Arduino #圧電素子 pic.twitter.com/lWXvb8UNqK

— いまうじ (@imauji) 2017年6月12日

##残りの予定

  • MIDI化 hairless
  • アプリかなにかでアサインした音出す
  • MIDI信号を映像側にも送る
  • 精度の向上
1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?