Initialize EEPROM
If you want to use EEPROM to store the settings, you will need to initialize the EEPROM.
Please write the sample code, example > EEPROM > InitializeEEPROM > InitializeEEPROM.ino, to your Arduino. Once it's written, the initialization is complete.
Coding
#include<hellodrum.h>
#include<MIDI.h>MIDI_CREATE_DEFAULT_INSTANCE();
//Please name your piezo.//The piezo named snare is connected to the A0 pin
HelloDrum snare(0);
//Setting
byte SNARE[6] = {
80, //sensitivity 10, //threshold20, //scantime20, //masktime38, //note1//curve type
};
voidsetup()
{
MIDI.begin(10);
snare.setCurve(SNARE[5]); //Set velocity curve
}
voidloop()
{
//Sensing
snare.singlePiezo(SNARE[0], SNARE[1], SNARE[2], SNARE[3]); //(sensitivity, threshold, scantime, masktime)//Sending MIDI signalsif (snare.hit == true) {
MIDI.sendNoteOn(SNARE[4], snare.velocity, 10); //(note, velocity, channel)
MIDI.sendNoteOff(SNARE[4], 0, 10);
}
}
Coding (MUX):
#include<hellodrum.h>
#include<MIDI.h>MIDI_CREATE_DEFAULT_INSTANCE();
//Define MUX Pins
HelloDrumMUX_4051 mux(2,3,4,0);//D2, D3, D4, A0//Please name your piezo.//The piezo named snare is connected to MUX 0 pin
HelloDrum snare(0);
//Setting
byte SNARE[6] = {
80, //sensitivity10, //threshold20, //scantime20, //masktime38, //note1//curve type
};
voidsetup()
{
MIDI.begin(10);
snare.setCurve(SNARE[5]); //Set velocity curve
}
voidloop()
{
//scanning all pin of mux
mux.scan();
//Sensing
snare.singlePiezoMUX(SNARE[0], SNARE[1], SNARE[2], SNARE[3]); //(sensitivity, threshold, scantime, masktime)//Sending MIDI signalsif (snare.hit == true) {
MIDI.sendNoteOn(SNARE[4], snare.velocity, 10); //(note, velocity, channel)
MIDI.sendNoteOff(SNARE[4], 0, 10);
}
}
lathoub Arduino-USBMIDI
If you are using atmega32u4 (Arduino Leonardo, Arduino Micro, Arduino Pro Micro...), you can use USB-MIDI library. No additional software is needed, the 32u4 is recognized as a MIDI device.
请发表评论