Construa bateria eletrônica com cristal piezo/Arduino - Ligue via USB - Explicação bateria Joystick

Build an Electronic Drum Kit with Piezo Crystal and Arduino - Connect via USB - Joystick Drum Kit Explanation In this video, I show how to assemble the circuit to build an electronic drum kit using an Arduino board. In the link below you can see how I built my drum kit. In this video, it was still without the circuit installed.    • Monte uma bateria de estudo/eletrônica par...   Arduino Source Code: const int threshold = 200; // threshold of knocking of the piezo unsigned long startTime = 0; // record the start time of the knock boolean active = 0; // represent whether it's in the "knocking" period unsigned long offTime = 150; // represent the ending time of the knocking boolean firstHit = 1; // represent whether it's the first time to knock boolean setTime = 0; // represent wether it has the starting time void midiMsg(byte cmd, byte pitch, byte velocity) { Serial.write(cmd); Serial.write(pitch); Serial.write(velocity); } void setup() { Serial.begin(115200); } void loop() { int val = analogRead(A0); //Serial.println(val); if((val 'here is the greater symbol, because YouTube doesn't allow you to put 'threshold' in the code)) { if (firstHit == 1) { // if it's the first time if (setTime == 0) { // if there is no starting time startTime = micros(); // recoding the starting time setTime = 1; } if (micros() - startTime 'here is the greater than symbol, because YouTube doesn't allow it in the code' 800) { firstHit = 0; setTime = 0; } } else { if((active == 0)) { val = map(val, threshold, 1023, 50, 127); midiMsg(0x99,47,val); active = 1; startTime = millis(); } } if((active == 1)) { if(millis() - startTime 'here is the greater than symbol, because YouTube doesn't allow it in the code' offTime){ active = 0; midiMsg(0x89,47,0); } } ATTENTION: I am not responsible for any actions you take during any experiment. The responsibility is yours. If necessary, seek help/consultation from a professional in the field. Caution Children: Always ask an adult for help. My name is Alex Baroni. I am a musician and electronics teacher. Want to study electronics? See more details on my website - www.cursobaroni.com.br Subscribe to the channel to stay updated on new videos.