Thursday, April 21, 2016

Piezo Drum Kit Quickstart Guide

Short Description
Piezo sensors in a five-piece drum kit drum kit lets in turn virtually anything. Play sounds when people interact with them in the past, I hang up my desk and couch Piezo sensors are used. This document is a simple introduction to working with Piezo elements. Once you Piezo sensors are able to detect the voltage levels, you can turn some sounds and start and stop your car, you can use them to start, etc. The possibilities are endless. This is because we used the drum sounds to generate an Arduino shield and MP3 player, we call this drum kit, but it is no hardware that can be used with percussive velocity input.


Necessity
Kit along with everything inside, we will use this guide to this item:
  • Soldering iron
  • Solder
  • arduino
How it Works
First, let's talk about the main components of the kit. The first element Piezo element itself. Piezo element has two leads, and when the pad is pressed, a small voltage across the material generates its leads. Piezo elements come in lots of shapes and sizes, but your finger press kit for detecting or more hits are well-tailored.

Other major components of the kit bag 1M ohm resistor. Piezo elements, such as the pull-down resistors are used in parallel with the voltage produced by the material to ensure a good read. This does not make sense now, do not worry, it will be explained later.

In this guide we will use the example code for an Arduino UNO, but this kit is an analog fashion a small voltage (5v less) can not be detected with any device that can be used.

How to use it
Out of the box, our first step is to wire a resistor element Piezo. We can only prevent jams and Piezo components Duemilanove female leads in the header. However, it could not constitute a proper connection, so we'll solder them together. If you've never welded before you, you will want to check out our welded 101 tutorials.

Connect the leads of the leads of the resistor element in a parallel fashion Piezo solder
Piezo Drum Kit Quickstart Guide
Piezo Drum Kit Quickstart Guide

To connect to the Arduino, a lead-in to your assembly line analog 0 (no analog inputs will work, but in this example we'll use A0) in the assembly line of a lead into the ground. When you're finished, it should look like.
Piezo Drum Kit Quickstart Guide
Piezo Drum Kit Quickstart Guide
Piezo elements are excited until the analog line will be zero volts in this circuit. When that happens, we must read the analog zero voltage line. In parallel with the resistor element Piezo element of a voltage of zero volts to the analog line is generated. When this happens, the voltage "override" by the weak pull-down resistor, voltage analog lines to be read, which is produced as a result. So if you want to know exactly why this works, be sure to read this on the use of pull-down resistors, a very high level of details.

Now we can start coding. The code for this step, we need two things: the analog line voltage reads, and then the voltage terminal prints. The following code is just that:

#define DRUM1 0    // Our analog pin

byte val = 0;      // Initializing the variable for the voltage value

void setup()
{
  Serial.begin(9600);  // Initializing the serial port at 9600 baud
}

void loop()
{
  val = analogRead(DRUM1);  // Read the voltage
  Serial.println(val, DEC); // Print the voltage to the terminal
}

Copy and paste this code onto your Arduino loaded. Once the code is uploaded, you open the Arduino IDE serial monitor. Make sure that it is set to 9600 baud. Once reset the board, Arduino know for sure voltage value (in this case is just an endless string of zero, 1M ohm pull-down due) to start printing.
Piezo Drum Kit Quickstart Guide
Piezo Drum Kit Quickstart Guide
Go ahead and hit your finger with a Piezo element. Change the value of the printed Notice. Hit it short, and the value of registered notes. Then hit a bit harder material, and that the target value registered more than ever. For this reason, I am more excited Piezo components, high voltage is generated it. Something like a MIDI keyboard does apply, then the "velocity" is called. Whether or not you Piezo material is very hard, too soft, or anywhere in between have been hit based on what may be caused by many different things. For instance, a loud drum sound when you hit the trigger element can be difficult, and when the material is slowly hitting a cool drum sound. You simply make the difference between hard and soft hits a threshold requirement. 200 of the code below a threshold set to distinguish between two types of hits.

#define DRUM1 0
#define THRESHOLD 200

byte val = 0;

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  val = analogRead(DRUM1);

  if(val > THRESHOLD) { Serial.println("HARD"); }
  else if(val > 0) { Serial.println("SOFT"); }
 
}

With this code, if the value is greater than the threshold value is detected by the analog pins, the print will be "difficult," otherwise, it will print "soft."

Conclusion
Piezo sensors that are on the principle of detecting voltages. From here, the application is up to you. Just solder resistors together with the rest of the Piezo elements, and other analog pins on the Arduino to use them in the exact same way. You can put anything you want to use to detect vibrations. Sound or light to begin using them; The possibilities are endless!

Resources
  • Datasheet (7BB-20-6L0)
  • arduino tutorials
  • Piezo elements add an additional increase in the number of "drums."
  • Create the ultimate music experience to combine with musical Shield.

No comments:

Post a Comment