HEllo,
im creating a midi in circuit for my sequencer, the question ist
how can I check if my circuit is right and the code also.
I use this circuit adn the code below:
http://www.instructables.com/file/FUJ0J5BFPBKZZB1/
The arduino is a mega and the midi in ist connected to RX0.
byte midi_start = 0xfa;
byte midi_stop = 0xfc;
byte midi_clock = 0xf8;
byte midi_continue = 0xfb;
int play_flag = 0;
byte data;
//midi in end
void setup() {
// set the states of the I/O pins:
for (int x = 0;x<16;x++) {
pinMode(LEDpins[x], OUTPUT);
pinMode(switchPins[x], INPUT);
}
pinMode(timePin1, INPUT);
pinMode(timePin2, INPUT);
pinMode(playPin, INPUT);
pinMode(holdPin, INPUT);
pinMode(dualPin, INPUT);
pinMode(midiin, INPUT);
// Set MIDI baud rate:
Serial.begin(31250);
Serial1.begin(31250);
// turn all notes off
noteOn(0xB00, 0x7B, 0x00);
noteOn(0xB01, 0x7B, 0x00);
noteOn(0xB02, 0x7B, 0x00);
noteOn(0xB03, 0x7B, 0x00);
noteOn(0xB04, 0x7B, 0x00);
noteOn(0xB05, 0x7B, 0x00);
noteOn(0xB06, 0x7B, 0x00);
noteOn(0xB07, 0x7B, 0x00);
blink(3);
timer_start = millis();
//------------------------------
// Control Voltage Section start
byte clr;
pinMode(DATAOUT, OUTPUT);
pinMode(DATAIN, INPUT);
pinMode(SPICLOCK,OUTPUT);
pinMode(SLAVESELECT,OUTPUT);
digitalWrite(SLAVESELECT,HIGH); //disable device
SPCR = (1<<SPE)|(1<<MSTR);
//SPCR = B01010000;
clr=SPSR;
clr=SPDR;
delay(10);
// Control Voltage Section end
//------------------------------
//---analog read timing
sbi(ADCSRA,ADPS2) ;
cbi(ADCSRA,ADPS1) ;
sbi(ADCSRA,ADPS0) ;
//-----------------------------
}
void loop() {
//Main sequence
//begin midi in here
if(Serial.available() > 0) {
data = Serial.read();
if(data == midi_start) {
play_flag = 1;
}
else if(data == midi_continue) {
play_flag = 1;
}
else if(data == midi_stop) {
play_flag = 0;
}
else if((data == midi_clock) && (play_flag == 1)) {
//
currentSwitchState[step] = digitalRead(switchPins[step]);
//mopdes are:
// normal sequencer
modeState = digitalRead(modePin);
if (modeState == 0) {
dualState = digitalRead(dualPin);
if (dualState == 1) {
currentSwitchState[step] = digitalRead(switchPins[step]);
playstep1(step, 8, 0);
if (step < 8) {
step++;
} else {
step = 0;
}
currentSwitchState[step2] = digitalRead(switchPins[step2]);
playstep2(step2, 15, 8);
if (step2 < 15) {
step2++;
} else {
step2 = 8;
}
} else {
playstep(step);
if (step < 15) {
step++;
} else {
step = 0;
}
}
} else {
loopstep(step);
if (step < 8) {
step++;
} else {
step = 0;
}
}
}
//else { blink(1); }
//
}
}