User:JackApplegarth/ENES-100/project 3

My Instructor's course page which points to this.

Problem Statement
Design a MIDI interface.

Week 1 Narrative
The first task of week 1 was to figure out a way to replace the HEF4067B multiplexer in the beat bearing board's wiring harness with the SN74LS151N multiplexer. The HEF4067B is a 16 to 2 mutliplexer, which means it takes 16 inputs and transmits them through 2 outputs. While the SN74LS151N is a 8 to 1 multiplexer, mean it takes 8 inputs and transmits them through 1 output. Below is the wiring harness using the HEF4067B.

Week 2 Narrative
Conceived an alternative wiring harness for the beat bearing board that does not require a multiplexer.

Wrote code to accommodate five analog switches.

/* * Sends midi signals to a synthesizer using 5 analog switches connected to pins 9-13 */

int switchPin13 = 13;             // switch is connected to pin 2 int switchPin11 = 11; int switchPin9 = 9; int switchPin7 = 7; int switchPin5 = 5; int val;                       // variable for reading the pin status void noteOn(int cmd, int pitch, int velocity) { //Sets what each of the 3 values in the "noteOn" function does Serial.write(cmd); //All MIDI protocol messages start with 0x90 to signify the start of a MIDI message Serial.write(pitch); //The note. Middle C (0x3C), for example Serial.write(velocity); //Volume of note }

void setup { Serial.begin(9600);          // set up Serial library at 9600 bps pinMode(switchPin13, INPUT);   // sets the digital pin as input to read switch pinMode(switchPin11, INPUT); pinMode(switchPin9, INPUT); pinMode(switchPin7, INPUT); pinMode(switchPin5, INPUT); Serial.begin(31250);         //MIDI protocol baud rate is 31250 bits per second

}

void loop{ // Channel 0 (hex = 0xC0) is alto sax (65 on the Gen MIDI Patch Map) hex = 0x41 Serial.write(0xC0); Serial.write(0x41); // Channel 1 (hex = 0xC1) is piano 0 (0 on patch map) hex = 0x00 Serial.write(0xC1); Serial.write(0x00); // Channel 9 (hex = 0xC9) is drums 0 (the drum line is always channel 9) Serial.write(0xC9); Serial.write(0x00); val = digitalRead(switchPin13);  // read input value and store it in val if (val == LOW) {              // check if the button is pressed noteOn(0x90, 0x48, 0x40);    // send sax midi signal to synth delay(1000); } if (val == HIGH) {              // check if the button is not pressed noteOn(0x90, 0x48, 0x00); }   // turn off sax synth signal

val = digitalRead(switchPin11);  // read input value and store it in val if (val == LOW) {              // check if the button is pressed noteOn(0x90, 0x40, 0x40);    // send E midi signal to synth delay(1000); } if (val == HIGH) {              // check if the button is not pressed noteOn(0x90, 0x48, 0x00); }   // turn off sax synth signal

val = digitalRead(switchPin9);  // read input value and store it in val if (val == LOW) {              // check if the button is pressed noteOn(0x90, 0x3E, 0x40);    // send D midi signal to synth delay(1000); } if (val == HIGH) {              // check if the button is not pressed noteOn(0x90, 0x48, 0x00); }   // turn off sax synth signal

val = digitalRead(switchPin7);  // read input value and store it in val if (val == LOW) {              // check if the button is pressed noteOn(0x90, 0x3C, 0x40);    // send C midi signal to synth delay(1000); } if (val == HIGH) {              // check if the button is not pressed noteOn(0x90, 0x48, 0x00); }   // turn off sax synth signal

val = digitalRead(switchPin5);  // read input value and store it in val if (val == LOW) {              // check if the button is pressed noteOn(0x90, 0x43, 0x40);    // send G midi signal to synth delay(1000); } if (val == HIGH) {              // check if the button is not pressed noteOn(0x90, 0x48, 0x00); }   // turn off sax synth signal

} Wired the new beat bearing board to the wiring harness and tested with the above code. Here is a VIDEO of the code working

Next steps: Figure out a way to connect the synthesizer to an arduino without using a MIDI shield, so that a 64 button shield can be attached to the arduino. The 64 button shield has the same function as a multiplexer, except with more inputs. This will allow all the switches on the beat bearing board to have inputs to the arduino.

Week 3 Narrative
Figured out a method to connect a MIDI cable to an Arduino without the use of a MIDI shield. This was necessary to attach a 64 button multiplexer shield to the Ardunio.

The 64 button multiplexer shield will allow all analog switches on the beat bearing board to be connected to the Arduino. Below is a diagram of the connection that will be used to attach the MIDI cable to the Arduino without the MIDI shield.

Next steps will be to make the connection shown in the above diagram and test it with the synthesizer by sending code from the Arduino to the synthesizer through the MIDI cable.

Week 4 Narrative
Wired the connection that was figured out in week 3 to connect a MIDI cable to an arduino without using a MIDI shield. There was a problem attaching the leads running from the arduino's 5V, GND, and Digital Pin 1 inputs because the MIDI cable available only had male connectors, and due to the metal casing surrounding the pins there was no room to wrap a lead around the pins, or attach a test hook.

Here is a VIDEO of the connection successfully sending a MIDI signal to the synthesizer without a MIDI shield.