0% found this document useful (0 votes)
9 views6 pages

ArduinoMegaDrumTest Ino

Kode

Uploaded by

DWI ALFAN HUDHA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views6 pages

ArduinoMegaDrumTest Ino

Kode

Uploaded by

DWI ALFAN HUDHA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

int notes=38;//snare

int noteb=36;//bass kick

int notehclosed=21; //closed pedal


int notehopen=20; //open pedal

int notehat; //hats closed (to be modified)

int piezobigs=0;
int piezobigb=0;

int piezobighat=0;

int hatarray[4]={100,100,100,100};

void setup(){
Serial.begin(31250);

void loop(){

int ground=analogRead(A0);// for arduino bleeding problems(electronic) ,ground a


analog pin and read it between readings

int piezovalues = analogRead(A1);


ground=analogRead(A0);

int piezovalueb = analogRead(A2);


ground=analogRead(A0);

int controlhihat = analogRead(A15);


ground=analogRead(A0);

int piezovaluehat = analogRead(A3);


ground=analogRead(A0);

/////////////////////////////////////////////////hihat pedal control

if(controlhihat > 50 && controlhihat <= 250)


hatarray[1]=50;
if(controlhihat<50 && hatarray[1]==50 ){

MIDI_send(144,notehclosed,80);

hatarray[1]=0;

if(controlhihat >250 && controlhihat <= 300)


hatarray[2]=50;

if(controlhihat>300 && hatarray[2]==50 && piezovaluehat <70){

MIDI_send(144,notehopen,20);

hatarray[2]=0;

if(controlhihat >= 0 && controlhihat < 30)


notehat=11;

if(controlhihat >= 30 && controlhihat < 130)


notehat=10;
if(controlhihat >= 130 && controlhihat < 200)
notehat=12;
if(controlhihat >= 200 && controlhihat < 800)
notehat=14;
if(controlhihat >= 800 && controlhihat < 1200)
notehat=16;
////////////////////////////////////////////////hihat pedal control

//////////////////////////////////////////snare///////////////////////////

if ( piezovalues> 5 ){
if( piezobigs < piezovalues)
{
piezobigs=piezovalues;

if (piezovalues < 5 && piezobigs > 0 ){


//Serial.println(piezobig);
/////////////////////////////////////////////

if(piezobigs >= 10 && piezobigs < 20 )


MIDI_send(144,notes,10);
if(piezobigs >= 20 && piezobigs < 30 )
MIDI_send(144,notes,20);
if(piezobigs >= 30 && piezobigs < 40 )
MIDI_send(144,notes,30);
if(piezobigs >= 40 && piezobigs < 60 )
MIDI_send(144,notes,40);
if(piezobigs >=60 && piezobigs < 80 )
MIDI_send(144,notes,50);

if(piezobigs >=80 && piezobigs < 100 )


MIDI_send(144,notes,60);
if(piezobigs >= 100 && piezobigs < 200 )
MIDI_send(144,notes,70);

if(piezobigs >= 200 && piezobigs < 300 )


MIDI_send(144,notes,80);
if(piezobigs >=300 && piezobigs < 400 )
MIDI_send(144,notes,90);
if(piezobigs > 400 && piezobigs < 600 )
MIDI_send(144,notes,100);
if(piezobigs >=600 && piezobigs <700 )
MIDI_send(144,notes,110);

if(piezobigs >=700 )
MIDI_send(144,notes,127);

MIDI_send(128,notes,0);

///////////////////////////////////////////////////////////

piezobigs=0;

///////////////////////////////////////snare//////////////////////////////

/////////////////////////////////////////////////
bass//////////////////////////////////////////////

if ( piezovalueb> 5 ){
if( piezobigb < piezovalueb)
{
piezobigb=piezovalueb;

if (piezovalueb < 5 && piezobigb > 0 ){

if(piezobigb >= 10 && piezobigb < 20 )


MIDI_send(144,noteb,10);
if(piezobigb >= 20 && piezobigb < 30 )
MIDI_send(144,noteb,20);
if(piezobigb >= 30 && piezobigb < 40 )
MIDI_send(144,noteb,30);
if(piezobigb >= 40 && piezobigb < 60 )
MIDI_send(144,noteb,40);
if(piezobigb >=60 && piezobigb < 80 )
MIDI_send(144,noteb,50);

if(piezobigb >=80 && piezobigb < 100 )


MIDI_send(144,noteb,60);
if(piezobigb >= 100 && piezobigb < 200 )
MIDI_send(144,noteb,70);

if(piezobigb >= 200 && piezobigb < 400 )


MIDI_send(144,noteb,80);
if(piezobigb >=400 && piezobigb < 600 )
MIDI_send(144,noteb,90);
if(piezobigb > 600 && piezobigb <800 )
MIDI_send(144,noteb,100);
if(piezobigb >=800 && piezobigb < 900 )
MIDI_send(144,noteb,110);

if(piezobigb >=900 )
MIDI_send(144,noteb,127);

MIDI_send(128,noteb,0);

piezobigb=0;

//////////////////////////////////////////////
bass////////////////////////////////////////////////////////////
/////////////////////////////////////////////////
hihat//////////////////////////////////////////////

if ( piezovaluehat> 5 ){
if( piezobighat < piezovaluehat)
{
piezobighat=piezovaluehat;

if (piezovaluehat < 5 && piezobighat > 0 ){

if(piezobighat >= 30 && piezobighat < 50 )


MIDI_send(144,notehat,10);
if(piezobighat >= 50 && piezobighat < 60 )
MIDI_send(144,notehat,20);
if(piezobighat >= 60 && piezobighat < 80 )
MIDI_send(144,notehat,30);

if(piezobighat >= 80 && piezobighat < 100 )


MIDI_send(144,notehat,40);
if(piezobighat >=100 && piezobighat < 150 )
MIDI_send(144,notehat,50);

if(piezobighat >=150 && piezobighat < 200 )


MIDI_send(144,notehat,60);

if(piezobighat >= 200 && piezobighat < 300 )


MIDI_send(144,notehat,70);

if(piezobighat >= 300 && piezobighat < 400 )


MIDI_send(144,notehat,80);
if(piezobighat >=400 && piezobighat < 500 )
MIDI_send(144,notehat,90);
if(piezobighat > 500 && piezobighat < 600 )
MIDI_send(144,notehat,100);
if(piezobighat >=600 && piezobighat < 700 )
MIDI_send(144,notehat,110);

if(piezobighat >=700 )
MIDI_send(144,notehat,127);

MIDI_send(128,notehat,0);
piezobighat=0;

//////////////////////////////////////////////
hihat////////////////////////////////////////////////////////////

}// mainloop

void MIDI_send(unsigned char MESSAGE, unsigned char PITCH, unsigned char VELOCITY)
{

Serial.write(MESSAGE);
Serial.write(PITCH);
Serial.write(VELOCITY);
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy