This is an Arduino-based MIDI controller.
Essentials:
When you move the joystick in any direction, or hit the button, you are simply closing a switch. The 5 switches (4 directions + 1 button) are connected to the digital input pins of the Arduino. The Arduino reads the state of the switches – open or closed – and sends the assigned MIDI note to the synthesizer.
Inside the gutted ET video game cartridge sits the Arduino. On the exterior, a 9-pin D-sub connector is mounted to plug in a standard Atari 2600 joystick (the joystick has not been modified), as well as a MIDI out jack to connect to a synthesizer, drum machine, etc.
Here’s a quick demo:
And some more fun:
CODE:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
/* --joyStick-- http://creativetechnical.ca/joystick/ MIDI 16-note pentatonic player digital LOW plays note ATARI 2600 JOYSTICK Joystick pin 1 connected to Arduino pin 2 Joystick pin 2 connected to Arduino pin 4 Joystick pin 3 connected to Arduino pin 5 Joystick pin 4 connected to Arduino pin 3 Joystick pin 6 connected to Arduino pin 6 Joystick pin 8 connected to Arduino GND MIDI: MIDI jack pin 5 connected to Arduino pin 1 (TX) MIDI jack pin 2 connected to ground MIDI jack pin 4 connected to +5V through 220-ohm resistor Attach a MIDI cable to the jack, then to a MIDI synth, and play music. Replace the following #define values to play different notes (decimal values) http://www.midimountain.com/midi/midi_note_numbers.html */ #define UP_NOTE 48 #define UP_RIGHT_NOTE 50 #define RIGHT_NOTE 52 #define DOWN_RIGHT_NOTE 55 #define DOWN_NOTE 57 #define DOWN_LEFT_NOTE 60 #define LEFT_NOTE 62 #define UP_LEFT_NOTE 64 #define BUTTON_UP_NOTE 67 #define BUTTON_UP_RIGHT_NOTE 69 #define BUTTON_RIGHT_NOTE 72 #define BUTTON_DOWN_RIGHT_NOTE 74 #define BUTTON_DOWN_NOTE 76 #define BUTTON_DOWN_LEFT_NOTE 79 #define BUTTON_LEFT_NOTE 81 #define BUTTON_UP_LEFT_NOTE 84 #define SWITCHCOUNT 5 //number of input switches #define MIDICMD_NOTEON 0x90 // MIDI command (Note On, Channel 0) #define DELAY 1 // variable for delay (in ms) byte pinarray[SWITCHCOUNT] = {2,3,4,5,6}; byte playarray[SWITCHCOUNT] = {HIGH,HIGH,HIGH,HIGH,HIGH}; #define PINUP 2 // joystick 'up' is connected to pin 2 #define PINRIGHT 3 // joystick 'right' is connected to pin 3 #define PINDOWN 4 // joystick 'down' is connected to pin 4 #define PINLEFT 5 // joystick 'left' is connected to pin 5 #define PINBUTTON 6 // joystick button is connected to pin 6 int stateUp = 0; // variable for reading the pin status int stateRight = 0; int stateDown = 0; int stateLeft = 0; int stateButton = 0; ///////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// void setup() { Serial.begin(31250); // Set MIDI baud rate pinMode(PINUP, INPUT_PULLUP); // Set the switch pin as input, and enable pullup resistor pinMode(PINRIGHT, INPUT_PULLUP); pinMode(PINDOWN, INPUT_PULLUP); pinMode(PINLEFT, INPUT_PULLUP); pinMode(PINBUTTON, INPUT_PULLUP); } ///////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// void loop() { for (int i = 0; i < SWITCHCOUNT; i++) //count from 0 to 4 { if (digitalRead(pinarray[i]) != playarray[i]) //check if state has changed { stateUp = digitalRead(PINUP); // read input value and store it in stateUp stateRight = digitalRead(PINRIGHT); stateDown = digitalRead(PINDOWN); stateLeft = digitalRead(PINLEFT); stateButton = digitalRead(PINBUTTON); // SendMIDI(0xB0, 123, 0); // Silence all notes //fake monosynth if (stateUp == LOW && stateRight == LOW && stateButton == LOW) { SendMIDI(MIDICMD_NOTEON, BUTTON_UP_RIGHT_NOTE, 127); } else if (stateRight == LOW && stateDown == LOW && stateButton == LOW) { SendMIDI(MIDICMD_NOTEON, BUTTON_DOWN_RIGHT_NOTE, 127); } else if (stateDown == LOW && stateLeft == LOW && stateButton == LOW) { SendMIDI(MIDICMD_NOTEON, BUTTON_DOWN_LEFT_NOTE, 127); } else if (stateLeft == LOW && stateUp == LOW && stateButton == LOW) { SendMIDI(MIDICMD_NOTEON, BUTTON_UP_LEFT_NOTE, 127); } else if (stateUp == LOW && stateButton == LOW) { SendMIDI(MIDICMD_NOTEON, BUTTON_UP_NOTE, 127); } else if (stateRight == LOW && stateButton == LOW) { SendMIDI(MIDICMD_NOTEON, BUTTON_RIGHT_NOTE, 127); } else if (stateDown == LOW && stateButton == LOW) { SendMIDI(MIDICMD_NOTEON, BUTTON_DOWN_NOTE, 127); } else if (stateLeft == LOW && stateButton == LOW) { SendMIDI(MIDICMD_NOTEON, BUTTON_LEFT_NOTE, 127); } // 8 Notes code ////////////////////////////////////////////////////////////////////////////// else if (stateUp == LOW && stateRight == LOW) { SendMIDI(MIDICMD_NOTEON, UP_RIGHT_NOTE, 127); } else if (stateRight == LOW && stateDown == LOW) { SendMIDI(MIDICMD_NOTEON, DOWN_RIGHT_NOTE, 127); } else if (stateDown == LOW && stateLeft == LOW) { SendMIDI(MIDICMD_NOTEON, DOWN_LEFT_NOTE, 127); } else if (stateLeft == LOW && stateUp == LOW) { SendMIDI(MIDICMD_NOTEON, UP_LEFT_NOTE, 127); } else if (stateUp == LOW) { SendMIDI(MIDICMD_NOTEON, UP_NOTE, 127); } else if (stateRight == LOW) { SendMIDI(MIDICMD_NOTEON, RIGHT_NOTE, 127); } else if (stateDown == LOW) { SendMIDI(MIDICMD_NOTEON, DOWN_NOTE, 127); } else if (stateLeft == LOW) { SendMIDI(MIDICMD_NOTEON, LEFT_NOTE, 127); } else { SendMIDI(0xB0, 123, 0); // Silence all notes } playarray[i] = !playarray[i]; // Put the present value in playarray. } } delay(DELAY); } ////////////////////////////////////////////////////////////////////////////////////////////// void SendMIDI(char cmd, char data1, char data2) //laserharp method { Serial.print(cmd); Serial.print(data1); Serial.print(data2); } |