hello, I am very new to arduino but I wanted to make my own project .. especially for Arduino Drum.
I have 6 months working on this project.. I think all run normally, but I find problem of the hi-hat controller when I uses sensors tcrt5000..
I could not find a solution in another forum and I would like to ask here ..
what I want is Arduino sends CC (Control Change) to the Drum Software (addictive drum 2) using TCRT5000 ..
I give a schematic and sketch that I use ..
unsigned char PadNote[16] = {69,99,3,36,46,6,79,0,50,10,11,12,13,60,38,71};
unsigned char status;
int PadCutOff[16] = {200,200,200,100,200,200,200,200,200,200,200,300,200,200,200,200};
int MaxPlayTime[16] = {35,25,25,25,25,25,25,25,25,40,25,40,25,25,25,25};
#define midichannel 0;
boolean activePad[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int PinPlayTime[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
boolean VelocityFlag = true;
int analogPin[2] = {A0,A1};
int pin = 0;
int hitavg = 0;
int pad = 0;
int r0 = 0;
int r1 = 0;
int r2 = 0;
int count = 0;
int multiplex1[8];
int multiplex2[8];
//*******************************************************************************************************************
// Setup
//*******************************************************************************************************************
void setup()
{
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
Serial.begin(115200); // connect to the serial port 115200
}
//*******************************************************************************************************************
// Main Program
//*******************************************************************************************************************
void loop(){
readSensors(0);
readSensors(1);
checkSensors(0);
checkSensors(1);
}
void readSensors (int analogPin) {
for(count=0; count <= 7; count++)
{
r2 = bitRead(count,0);
r1 = bitRead(count,1);
r0 = bitRead(count,2);
digitalWrite(2, r0);
digitalWrite(3, r1);
digitalWrite(4, r2);
if(analogPin==0) {
multiplex1[count] = analogRead(analogPin);
}
else if(analogPin==1) {
multiplex2[count] = analogRead(analogPin);
}
}
}
void checkSensors (int analogPin) {
for(int pin=0; pin <=7; pin++) {
if(analogPin==0) {
hitavg = multiplex1[pin];
pad=pin;
}
else if(analogPin==1) {
hitavg = multiplex2[pin];
pad=pin+8;
}
if((hitavg > PadCutOff[pad])) {
if((activePad[pad] == false)) {
if(VelocityFlag == true) {
hitavg = (hitavg / 8) -1;
}
else {
hitavg = 127;
}
MIDI_TX(144,PadNote[pad],hitavg);
PinPlayTime[pad] = 0;
activePad[pad] = true;
}
else {
PinPlayTime[pad] = PinPlayTime[pad] + 1;
}
}
else if((activePad[pad] == true)) {
PinPlayTime[pad] = PinPlayTime[pad] + 1;
if(PinPlayTime[pad] > MaxPlayTime[pad]) {
activePad[pad] = false;
MIDI_TX(128,PadNote[pad],0);
}
}
}
}
void MIDI_TX(unsigned char MESSAGE, unsigned char PITCH, unsigned char VELOCITY) {
status = MESSAGE + midichannel;
Serial.write(status);
Serial.write(PITCH);
Serial.write(VELOCITY);
}
As you can see in the schematic, HCC (hihat control change) is P4 connect to the CD4051 when seen in Sketch .. pins are connected with HCC is no 99..
I'm sorry if my english is very bad ..

