レーザーハープのコードBeta

#include <LiquidCrystal.h>

#define NOTE_ON 144
#define CONTROLCHANGE 176
#define ALLSOUNDOFF 120
#define SensorsNumber 6 //number of photo sensor
#define Legato 10
#define Limit 710

LiquidCrystal lcd(0, 1, 2, 3, 4, 5);

const int RightSW=13, LeftSW=10, ToggleDown=12, ToggleUp=11;
int nLB=0,nLM=1,nLT=2,nRB=3,nRM=4,nRT=5,vLB=1,vLM=1,vLT=1,vRB=1,vRM=1,vRT=1; //n=note,v=velocity
int Input[SensorsNumber] = {0,1,2,4,5,3};
int Note[SensorsNumber] = {nRT,nRM,nRB,nLT,nLM,nLB};
int Velocity[SensorsNumber] = {vRT,vRM,vRB,vLT,vLM,vLB};
short Counter[Sensorsnumber]; //change to int

void sendMidi(int cmd, int pitch, int velocity);
void Evaluate(int Value, int Note, int State, int Velocity);

//LB=LeftBottom(pin3),LM=LeftMiddle(pin5),LT=LeftTop(pin4),RB=RightBottom(pin2),RM=RightMiddle(pin1),RT=RightTop(pin0)

void sendMidi(int cmd, int pitch, int velocity) {
Serial.write(cmd);
Serial.write(pitch);
Serial.write(velocity);
}

int Evaluate(int Pin){
int Status = 0;
//thanks to developer who establish this function:https://jumbleat.com/2016/12/01/revision_of_avoiding_chatter/
if(1000 < analogRead(Input[Pin])){
Counter[Pin]++; //increase number
if(Counter[Pin] > Limit){ //when count get limitance
Counter[Pin] = Limit;
}
}else{
if(Counter[Pin] > Legato){
Status = 3; //stop shading
}
Counter[Pin] = 0;
}

if(Counter[Pin] > Legato){
Status = 2; //while shading
}
else if(Counter[Pin] == Legato){
Status = 1; //start shading
}

return Status;
}

void setup() { //setting up pinmode, LCD and MIDI
Serial.begin(31250);
pinMode(RightSW,INPUT); //now developing laser harp systems with switches
pinMode(LeftSW,INPUT);
pinMode(ToggleDown,INPUT);
pinMode(ToggleUp,INPUT);
lcd.begin(16, 2);
sendMidi(CONTROLCHANGE, ALLSOUNDOFF, 0);
}

void loop(){
for(int n = 0; n < SensorsNumber; n++){
int Status = Evaluate(n);
if(Status == 1){
sendMidi(NOTE_ON, Note[n], Velocity[n]);
}
else if(Status == 3){
sendMidi(NOTE_ON, Note[n], 0); //velocity 0 means note off
}
}
}