author
7CommentsJoined August 2nd, 2015
Mechatronic's student
  • RAFALAMAO made the instructable Arduino Xylophone1 year ago
    Arduino Xylophone

    Thank you very much! :DI made a drum set but I used Xylophone code for only 5 piezo.This is the Arduino's code :D//Xylophone//Adapted for an ArduinoMega//from Jenna deBoisblanc and Spiekenzie Labs initial code//*******************************************************************************************************************// User settable variables//*******************************************************************************************************************int pinRead;char pinAssignments[5] ={'A0','A1','A2','A3','A4'};byte PadNote[5] = {53,69,11,57,36}; // MIDI notes from 0 to 127 (Mid C = 60)//53 Campana//69 Tarola//11 Hithat cerrado//57 Crash//36 Bomboint PadCutOff[5] = {500,200,350,300,400}; // Minimum Analog value to cause a drum hitint MaxPlayTime[5] = {90,90,90,90,90}; // ...

    see more »

    Thank you very much! :DI made a drum set but I used Xylophone code for only 5 piezo.This is the Arduino's code :D//Xylophone//Adapted for an ArduinoMega//from Jenna deBoisblanc and Spiekenzie Labs initial code//*******************************************************************************************************************// User settable variables//*******************************************************************************************************************int pinRead;char pinAssignments[5] ={'A0','A1','A2','A3','A4'};byte PadNote[5] = {53,69,11,57,36}; // MIDI notes from 0 to 127 (Mid C = 60)//53 Campana//69 Tarola//11 Hithat cerrado//57 Crash//36 Bomboint PadCutOff[5] = {500,200,350,300,400}; // Minimum Analog value to cause a drum hitint MaxPlayTime[5] = {90,90,90,90,90}; // Cycles before a 2nd hit is allowed#define midichannel 1; // MIDI channel from 0 to 15 (+1 in "real world")boolean VelocityFlag = true; // Velocity ON (true) or OFF (false)//*******************************************************************************************************************// Internal Use Variables//*******************************************************************************************************************boolean activePad[5] = {0,0,0,0,0}; // Array of flags of pad currently playingint PinPlayTime[5] = {0,0,0,0,0}; // Counter since pad started to playbyte status1;int pin = 0;int hitavg = 0;//*******************************************************************************************************************// Setup//*******************************************************************************************************************void setup(){Serial.begin(57600); // SET HAIRLESS TO THE SAME BAUD RATE IN THE SETTING}//*******************************************************************************************************************// Main Program//*******************************************************************************************************************void loop(){for(int pin=0; pin < 5; pin++) //{//int pin = 3;// for (pinRead=0; pinRead < 16, pin++){hitavg = analogRead(pinAssignments[pin]);//Serial.println(hitavg);// read the input pinif((hitavg > PadCutOff[pin])){if((activePad[pin] == false)){if(VelocityFlag == true){hitavg=127;//hitavg = 127 / ((1023 - PadCutOff[pin]) / (hitavg - PadCutOff[pin])); // With full range (Too sensitive ?)//hitavg = (hitavg / 8) -1 ; //8 // Upper range}else{hitavg = 127;}MIDI_TX(144,PadNote[pin],hitavg); //note onPinPlayTime[pin] = 0;activePad[pin] = true;}else{PinPlayTime[pin] = PinPlayTime[pin] + 1;}}else if((activePad[pin] == true)){PinPlayTime[pin] = PinPlayTime[pin] + 1;if(PinPlayTime[pin] > MaxPlayTime[pin]){activePad[pin] = false;MIDI_TX(144,PadNote[pin],0);}}}}//*******************************************************************************************************************// Transmit MIDI Message//*******************************************************************************************************************void MIDI_TX(byte MESSAGE, byte PITCH, byte VELOCITY){status1 = MESSAGE + midichannel;Serial.write(status1);Serial.write(PITCH);Serial.write(VELOCITY);}Regards :D

    View Instructable »
  • RAFALAMAO commented on audreyobscura's instructable Arduino Xylophone1 year ago
    Arduino Xylophone

    Try with this code, dude:AND REMEMBER CHANGE BAUD RATE TO 57600 IN HAIRLESS/FILE/PREFERENCES//Xylophone//Adapted for an ArduinoMega//from Jenna deBoisblanc and Spiekenzie Labs initial code//*******************************************************************************************************************// User settable variables//*******************************************************************************************************************int pinRead;char pinAssignments[12] ={'A0','A1','A2','A3','A4','A5','A6','A7','A8','A9','A10','A11'};byte PadNote[12] = {57,58,59,60,61,62,63,64,65,66,67,68}; // MIDI notes from 0 to 127 (Mid C = 60)int PadCutOff[12] ={400,400,200,800,400,400,400,400,400,400,400,400}; // Minimum Analog value to cause a drum hitint MaxPlayTime[12] = {90,90,90,90,90...

    see more »

    Try with this code, dude:AND REMEMBER CHANGE BAUD RATE TO 57600 IN HAIRLESS/FILE/PREFERENCES//Xylophone//Adapted for an ArduinoMega//from Jenna deBoisblanc and Spiekenzie Labs initial code//*******************************************************************************************************************// User settable variables//*******************************************************************************************************************int pinRead;char pinAssignments[12] ={'A0','A1','A2','A3','A4','A5','A6','A7','A8','A9','A10','A11'};byte PadNote[12] = {57,58,59,60,61,62,63,64,65,66,67,68}; // MIDI notes from 0 to 127 (Mid C = 60)int PadCutOff[12] ={400,400,200,800,400,400,400,400,400,400,400,400}; // Minimum Analog value to cause a drum hitint MaxPlayTime[12] = {90,90,90,90,90,90,90,90,90,90,90,90}; // Cycles before a 2nd hit is allowed#define midichannel 1; // MIDI channel from 0 to 15 (+1 in "real world")boolean VelocityFlag = true; // Velocity ON (true) or OFF (false)//*******************************************************************************************************************// Internal Use Variables//*******************************************************************************************************************boolean activePad[12] = {0,0,0,0,0,0,0,0,0,0,0,0}; // Array of flags of pad currently playingint PinPlayTime[12] = {0,0,0,0,0,0,0,0,0,0,0,0}; // Counter since pad started to playbyte status1;int pin = 0;int hitavg = 0;//*******************************************************************************************************************// Setup//*******************************************************************************************************************void setup(){Serial.begin(57600); // connect to the serial port 115200}//*******************************************************************************************************************// Main Program//*******************************************************************************************************************void loop(){for(int pin=0; pin < 12; pin++) //{//int pin = 3;// for (pinRead=0; pinRead < 16, pin++){hitavg = analogRead(pinAssignments[pin]);//Serial.println(hitavg);// read the input pinif((hitavg > PadCutOff[pin])){if((activePad[pin] == false)){if(VelocityFlag == true){// hitavg = 127 / ((1023 - PadCutOff[pin]) / (hitavg - PadCutOff[pin])); // With full range (Too sensitive ?)hitavg = (hitavg / 8) -1 ; // Upper range}else{hitavg = 127;}MIDI_TX(144,PadNote[pin],hitavg); //note onPinPlayTime[pin] = 0;activePad[pin] = true;}else{PinPlayTime[pin] = PinPlayTime[pin] + 1;}}else if((activePad[pin] == true)){PinPlayTime[pin] = PinPlayTime[pin] + 1;if(PinPlayTime[pin] > MaxPlayTime[pin]){activePad[pin] = false;MIDI_TX(144,PadNote[pin],0);}}}}//*******************************************************************************************************************// Transmit MIDI Message//*******************************************************************************************************************void MIDI_TX(byte MESSAGE, byte PITCH, byte VELOCITY){status1 = MESSAGE + midichannel;Serial.write(status1);Serial.write(PITCH);Serial.write(VELOCITY);}

    View Instructable »
  • RAFALAMAO commented on anouskadg's instructable MIDI Arduino Drums1 year ago
    MIDI Arduino Drums

    Thank you very much dude! :DI made my own :3, and i used Xylophone code for only 5 piezo.This is the Arduino's code :D//Xylophone//Adapted for an ArduinoMega//from Jenna deBoisblanc and Spiekenzie Labs initial code//*******************************************************************************************************************// User settable variables//*******************************************************************************************************************int pinRead;char pinAssignments[5] ={'A0','A1','A2','A3','A4'};byte PadNote[5] = {53,69,11,57,36}; // MIDI notes from 0 to 127 (Mid C = 60)//53 Campana//69 Tarola//11 Hithat cerrado//57 Crash//36 Bomboint PadCutOff[5] = {500,200,350,300,400}; // Minimum Analog value to cause a drum hitint MaxPlayTime[5] = {90,90,90,90,90}...

    see more »

    Thank you very much dude! :DI made my own :3, and i used Xylophone code for only 5 piezo.This is the Arduino's code :D//Xylophone//Adapted for an ArduinoMega//from Jenna deBoisblanc and Spiekenzie Labs initial code//*******************************************************************************************************************// User settable variables//*******************************************************************************************************************int pinRead;char pinAssignments[5] ={'A0','A1','A2','A3','A4'};byte PadNote[5] = {53,69,11,57,36}; // MIDI notes from 0 to 127 (Mid C = 60)//53 Campana//69 Tarola//11 Hithat cerrado//57 Crash//36 Bomboint PadCutOff[5] = {500,200,350,300,400}; // Minimum Analog value to cause a drum hitint MaxPlayTime[5] = {90,90,90,90,90}; // Cycles before a 2nd hit is allowed#define midichannel 1; // MIDI channel from 0 to 15 (+1 in "real world")boolean VelocityFlag = true; // Velocity ON (true) or OFF (false)//*******************************************************************************************************************// Internal Use Variables//*******************************************************************************************************************boolean activePad[5] = {0,0,0,0,0}; // Array of flags of pad currently playingint PinPlayTime[5] = {0,0,0,0,0}; // Counter since pad started to playbyte status1;int pin = 0;int hitavg = 0;//*******************************************************************************************************************// Setup//*******************************************************************************************************************void setup(){Serial.begin(57600); // SET HAIRLESS TO THE SAME BAUD RATE IN THE SETTING}//*******************************************************************************************************************// Main Program//*******************************************************************************************************************void loop(){for(int pin=0; pin < 5; pin++) //{//int pin = 3;// for (pinRead=0; pinRead < 16, pin++){hitavg = analogRead(pinAssignments[pin]);//Serial.println(hitavg);// read the input pinif((hitavg > PadCutOff[pin])){if((activePad[pin] == false)){if(VelocityFlag == true){hitavg=127;//hitavg = 127 / ((1023 - PadCutOff[pin]) / (hitavg - PadCutOff[pin])); // With full range (Too sensitive ?)//hitavg = (hitavg / 8) -1 ; //8 // Upper range}else{hitavg = 127;}MIDI_TX(144,PadNote[pin],hitavg); //note onPinPlayTime[pin] = 0;activePad[pin] = true;}else{PinPlayTime[pin] = PinPlayTime[pin] + 1;}}else if((activePad[pin] == true)){PinPlayTime[pin] = PinPlayTime[pin] + 1;if(PinPlayTime[pin] > MaxPlayTime[pin]){activePad[pin] = false;MIDI_TX(144,PadNote[pin],0);}}}}//*******************************************************************************************************************// Transmit MIDI Message//*******************************************************************************************************************void MIDI_TX(byte MESSAGE, byte PITCH, byte VELOCITY){status1 = MESSAGE + midichannel;Serial.write(status1);Serial.write(PITCH);Serial.write(VELOCITY);}Regards :D

    Yes dude!You only need to change tone number, check this example of my modiffication code://Xylophone//Adapted for an ArduinoMega//from Jenna deBoisblanc and Spiekenzie Labs initial code//*******************************************************************************************************************// User settable variables//*******************************************************************************************************************int pinRead;char pinAssignments[5] ={'A0','A1','A2','A3','A4'};byte PadNote[5] = {53,69,11,57,36}; // MIDI notes from 0 to 127 (Mid C = 60)//53 Campana//69 Tarola//11 Hithat cerrado//57 Crash//36 Bomboint PadCutOff[5] = {500,200,350,300,400}; // Minimum Analog value to cause a drum hitint MaxPlayTime[5] = {90,90,90,90,90}; // Cycles before a 2nd hit...

    see more »

    Yes dude!You only need to change tone number, check this example of my modiffication code://Xylophone//Adapted for an ArduinoMega//from Jenna deBoisblanc and Spiekenzie Labs initial code//*******************************************************************************************************************// User settable variables//*******************************************************************************************************************int pinRead;char pinAssignments[5] ={'A0','A1','A2','A3','A4'};byte PadNote[5] = {53,69,11,57,36}; // MIDI notes from 0 to 127 (Mid C = 60)//53 Campana//69 Tarola//11 Hithat cerrado//57 Crash//36 Bomboint PadCutOff[5] = {500,200,350,300,400}; // Minimum Analog value to cause a drum hitint MaxPlayTime[5] = {90,90,90,90,90}; // Cycles before a 2nd hit is allowed#define midichannel 1; // MIDI channel from 0 to 15 (+1 in "real world")boolean VelocityFlag = true; // Velocity ON (true) or OFF (false)//*******************************************************************************************************************// Internal Use Variables//*******************************************************************************************************************boolean activePad[5] = {0,0,0,0,0}; // Array of flags of pad currently playingint PinPlayTime[5] = {0,0,0,0,0}; // Counter since pad started to playbyte status1;int pin = 0;int hitavg = 0;//*******************************************************************************************************************// Setup//*******************************************************************************************************************void setup(){Serial.begin(57600); // SET HAIRLESS TO THE SAME BAUD RATE IN THE SETTING}//*******************************************************************************************************************// Main Program//*******************************************************************************************************************void loop(){for(int pin=0; pin < 5; pin++) //{//int pin = 3;// for (pinRead=0; pinRead < 16, pin++){hitavg = analogRead(pinAssignments[pin]);//Serial.println(hitavg);// read the input pinif((hitavg > PadCutOff[pin])){if((activePad[pin] == false)){if(VelocityFlag == true){hitavg=127;//hitavg = 127 / ((1023 - PadCutOff[pin]) / (hitavg - PadCutOff[pin])); // With full range (Too sensitive ?)//hitavg = (hitavg / 8) -1 ; //8 // Upper range}else{hitavg = 127;}MIDI_TX(144,PadNote[pin],hitavg); //note onPinPlayTime[pin] = 0;activePad[pin] = true;}else{PinPlayTime[pin] = PinPlayTime[pin] + 1;}}else if((activePad[pin] == true)){PinPlayTime[pin] = PinPlayTime[pin] + 1;if(PinPlayTime[pin] > MaxPlayTime[pin]){activePad[pin] = false;MIDI_TX(144,PadNote[pin],0);}}}}//*******************************************************************************************************************// Transmit MIDI Message//*******************************************************************************************************************void MIDI_TX(byte MESSAGE, byte PITCH, byte VELOCITY){status1 = MESSAGE + midichannel;Serial.write(status1);Serial.write(PITCH);Serial.write(VELOCITY);}Regards :D

    Hi dude :DCan did you can do it works or need help? :)

    View Instructable »
  • RAFALAMAO made the instructable MIDI Arduino Drums1 year ago
    MIDI Arduino Drums

    Thank you very much due! :DI made my own :3, and i used it Xylophone code.

    View Instructable »