Components and supplies
18
Resistor 1k ohm
1
Board
1
Arduino UNO
18
LED (generic)
Tools and machines
1
programmer USB Asp
Apps and platforms
1
AvrDudess
1
Arduino IDE
Project description
Code
Kod for Decoder MIDI Arduino Mega for GrandOrgue or Hauptwerk
c_cpp
1// Kod for Decoder MIDI Arduino Mega for GrandOrgue or Hauptwerk 2#include <MIDI.h> // Add Midi Library 3 4//#define LED 13 5//#define LED2 12// Arduino Board LED is on Pin 13 6 7//Create an instance of the library with default name, serial port and settings 8MIDI_CREATE_DEFAULT_INSTANCE(); 9 10void setup() { 11 12pinMode (A0, OUTPUT); // Set Arduino board analog pins to output 13digitalWrite (A0, HIGH); 14pinMode (A1, OUTPUT); 15digitalWrite (A1, HIGH); 16pinMode (A2, OUTPUT); 17digitalWrite (A2, HIGH); 18pinMode (A3, OUTPUT); 19digitalWrite (A3, HIGH); 20pinMode (A4, OUTPUT); 21digitalWrite (A4, HIGH); 22pinMode (A5, OUTPUT); 23digitalWrite (A5, HIGH); 24pinMode (A6, OUTPUT); 25digitalWrite (A6, HIGH); 26pinMode (A7, OUTPUT); 27digitalWrite (A7, HIGH); 28pinMode (A8, OUTPUT); 29digitalWrite (A8, HIGH); 30pinMode (A9, OUTPUT); 31digitalWrite (A9, HIGH); 32pinMode (A10, OUTPUT); 33digitalWrite (A10, HIGH); 34pinMode (A11, OUTPUT); 35digitalWrite (A11, HIGH); 36pinMode (A12, OUTPUT); 37digitalWrite (A12, HIGH); 38pinMode (A13, OUTPUT); 39digitalWrite (A13, HIGH); 40pinMode (A14, OUTPUT); 41digitalWrite (A14, HIGH); 42pinMode (A15, OUTPUT); 43digitalWrite (A15, HIGH); 44 45 46 47 for (int a=2; a<54; a++) 48{ 49pinMode (a, OUTPUT); // Set Arduino board digital pins to output 50digitalWrite (a, HIGH); // Set Arduino board digitsl pins to KIGH 51 52} 53 54 55// self-test 56 for (int a=14; a<36; a++) 57{ 58digitalWrite (a, LOW); // Set Arduino board digital pins to HIGH 59delay(250); 60digitalWrite (a, HIGH); // Set Arduino board digital pins to LOW 61delay(50); 62} 63 64 65 66 67 68 69 70 71 72 MIDI.begin(MIDI_CHANNEL_OMNI); // Initialize the Midi Library. 73 // OMNI sets it to listen to all channels.. MIDI.begin(2) would set it 74 // to respond to notes on channel 2 only. 75 MIDI.setHandleNoteOn(MyHandleNoteOn); // This is important!! This command 76 // tells the Midi Library which function you want to call when a NOTE ON command 77 // is received. In this case it's "MyHandleNoteOn". 78 MIDI.setHandleNoteOff(MyHandleNoteOff); // This command tells the Midi Library 79 // to call "MyHandleNoteOff" when a NOTE OFF command is received. 80} 81 82void loop() { // Main loop 83 MIDI.read(); // Continuously check if Midi data has been received. 84} 85 86// MyHandleNoteON is the function that will be called by the Midi Library 87// when a MIDI NOTE ON message is received. 88// It will be passed bytes for Channel, Pitch, and Velocity 89void MyHandleNoteOn(byte channel, byte pitch, byte velocity) { 90 switch (pitch) { 91 case 54+34: 92 digitalWrite (A0, LOW); 93 break; 94 case 55+34: 95 digitalWrite (A1, LOW); 96 break; 97 case 56+34: 98 digitalWrite (A2, LOW); 99 break; 100 case 57+34: 101 digitalWrite (A3, LOW); 102 break; 103 case 58+34: 104 digitalWrite (A4, LOW); 105 break; 106 case 59+34: 107 digitalWrite (A5, LOW); 108 break; 109 case 60+34: 110 digitalWrite (A6, LOW); 111 break; 112 case 61+34: 113 digitalWrite (A7, LOW); 114 break; 115 case 62+34: 116 digitalWrite (A8, LOW); 117 break; 118 case 63+34: 119 digitalWrite (A9, LOW); 120 break; 121 case 64+34: 122 digitalWrite (A10, LOW); 123 break; 124 case 65+34: 125 digitalWrite (A11, LOW); 126 break; 127 case 66+34: 128 digitalWrite (A12, LOW); 129 break; 130 case 67+34: 131 digitalWrite (A13, LOW); 132 break; 133 case 68+34: 134 digitalWrite (A14, LOW); 135 break; 136 case 69+34: 137 digitalWrite (A15, LOW); 138 break; 139 140 141 default: 142 // if nothing else matches, do the default 143 // default is optional 144 break; 145} 146 for (int a=2; a<54; a++) 147{ 148 if (pitch == 34+a) { 149digitalWrite (a, LOW); // Set Arduino board pin 13 to output 150 } 151} 152 153 154 155 156} 157 158// MyHandleNoteOFF is the function that will be called by the Midi Library 159// when a MIDI NOTE OFF message is received. 160// * A NOTE ON message with Velocity = 0 will be treated as a NOTE OFF message * 161// It will be passed bytes for Channel, Pitch, and Velocity 162void MyHandleNoteOff(byte channel, byte pitch, byte velocity) { 163 switch (pitch) { 164 case 54+34: 165 digitalWrite (A0, HIGH); 166 break; 167 case 55+34: 168 digitalWrite (A1, HIGH); 169 break; 170 case 56+34: 171 digitalWrite (A2, HIGH); 172 break; 173 case 57+34: 174 digitalWrite (A3, HIGH); 175 break; 176 case 58+34: 177 digitalWrite (A4, HIGH); 178 break; 179 case 59+34: 180 digitalWrite (A5, HIGH); 181 break; 182 case 60+34: 183 digitalWrite (A6, HIGH); 184 break; 185 case 61+34: 186 digitalWrite (A7, HIGH); 187 break; 188 case 62+34: 189 digitalWrite (A8, HIGH); 190 break; 191 case 63+34: 192 digitalWrite (A9, HIGH); 193 break; 194 case 64+34: 195 digitalWrite (A10, HIGH); 196 break; 197 case 65+34: 198 digitalWrite (A11, HIGH); 199 break; 200 case 66+34: 201 digitalWrite (A12, HIGH); 202 break; 203 case 67+34: 204 digitalWrite (A13, HIGH); 205 break; 206 case 68+34: 207 digitalWrite (A14, HIGH); 208 break; 209 case 69+34: 210 digitalWrite (A15, HIGH); 211 break; 212 213 214 default: 215 // if nothing else matches, do the default 216 // default is optional 217 break; 218} 219 220 for (int a=2; a<54; a++) 221{ 222 if (pitch == 34+a) { 223digitalWrite (a, HIGH); // Set Arduino board pin 13 to output 224 } 225} 226 227 228}
Kod for Small Dekoder MIDI - Arduino UNO for GrandOrgue or Hauptwerk
c_cpp
1// Small dekoder Midi - R. Milewski 2#include <MIDI.h> // Add Midi Library 3 4//#define LED 13 5//#define LED2 12// Arduino Board LED is on Pin 13 6 7//Create an instance of the library with default name, serial port and settings 8MIDI_CREATE_DEFAULT_INSTANCE(); 9 10void setup() { 11 12pinMode (A0, OUTPUT); // Set Arduino board analog pins to output 13digitalWrite (A0, LOW); 14pinMode (A1, OUTPUT); 15digitalWrite (A1, LOW); 16pinMode (A2, OUTPUT); 17digitalWrite (A2, LOW); 18pinMode (A3, OUTPUT); 19digitalWrite (A3, LOW); 20pinMode (A4, OUTPUT); 21digitalWrite (A4, LOW); 22pinMode (A5, OUTPUT); 23 24 25 26 for (int a=2; a<14; a++) 27{ 28pinMode (a, OUTPUT); // Set Arduino board digital pins to output 29digitalWrite (a, LOW); // Set Arduino board digitsl pins to KIGH 30 31} 32 33 34// self-test 35 for (int a=2; a<14; a++) 36{ 37digitalWrite (a, HIGH); // Set Arduino board digital pins to HIGH 38delay(250); 39digitalWrite (a, LOW); // Set Arduino board digital pins to LOW 40delay(50); 41} 42 43 44 45 46 47 48 49 50 51 MIDI.begin(MIDI_CHANNEL_OMNI); // Initialize the Midi Library. 52 // OMNI sets it to listen to all channels.. MIDI.begin(2) would set it 53 // to respond to notes on channel 2 only. 54 MIDI.turnThruOff(); // Turn off loop Midi IN to OUT 55 MIDI.setHandleNoteOn(MyHandleNoteOn); // This is important!! This command 56 // tells the Midi Library which function you want to call when a NOTE ON command 57 // is received. In this case it's "MyHandleNoteOn". 58 MIDI.setHandleNoteOff(MyHandleNoteOff); // This command tells the Midi Library 59 // to call "MyHandleNoteOff" when a NOTE OFF command is received. 60} 61 62void loop() { // Main loop 63 MIDI.read(); // Continuously check if Midi data has been received. 64} 65 66// MyHandleNoteON is the function that will be called by the Midi Library 67// when a MIDI NOTE ON message is received. 68// It will be passed bytes for Channel, Pitch, and Velocity 69void MyHandleNoteOn(byte channel, byte pitch, byte velocity) { 70 switch (pitch) { 71 case 54+34: 72 digitalWrite (A0, HIGH); 73 break; 74 case 55+34: 75 digitalWrite (A1, HIGH); 76 break; 77 case 56+34: 78 digitalWrite (A2,HIGH); 79 break; 80 case 57+34: 81 digitalWrite (A3, HIGH); 82 break; 83 case 58+34: 84 digitalWrite (A4, HIGH); 85 break; 86 case 59+34: 87 digitalWrite (A5, HIGH); 88 break; 89 90 91 92 default: 93 // if nothing else matches, do the default 94 // default is optional 95 break; 96} 97 for (int a=2; a<14; a++) 98{ 99 if (pitch == 58+a) { 100digitalWrite (a, HIGH); // Set Arduino board pin 13 to output 101 } 102} 103 104 105 106 107} 108 109// MyHandleNoteOFF is the function that will be called by the Midi Library 110// when a MIDI NOTE OFF message is received. 111// * A NOTE ON message with Velocity = 0 will be treated as a NOTE OFF message * 112// It will be passed bytes for Channel, Pitch, and Velocity 113void MyHandleNoteOff(byte channel, byte pitch, byte velocity) { 114 switch (pitch) { 115 case 54+34: 116 digitalWrite (A0, LOW); 117 break; 118 case 55+34: 119 digitalWrite (A1, LOW); 120 break; 121 case 56+34: 122 digitalWrite (A2, LOW); 123 break; 124 case 57+34: 125 digitalWrite (A3, LOW); 126 break; 127 case 58+34: 128 digitalWrite (A4, LOW); 129 break; 130 case 59+34: 131 digitalWrite (A5, LOW); 132 break; 133 134 default: 135 // if nothing else matches, do the default 136 // default is optional 137 break; 138} 139 140 for (int a=2; a<14; a++) 141{ 142 if (pitch == 58+a) { 143digitalWrite (a, LOW); // Set Arduino board pin 13 to output 144 } 145} 146 147 148}
Kod for Decoder MIDI Arduino Mega for GrandOrgue or Hauptwerk
c_cpp
1// Kod for Decoder MIDI Arduino Mega for GrandOrgue or Hauptwerk 2#include <MIDI.h> // Add Midi Library 3 4//#define LED 13 5//#define LED2 12// Arduino Board LED is on Pin 13 6 7//Create an instance of the library with default name, serial port and settings 8MIDI_CREATE_DEFAULT_INSTANCE(); 9 10void setup() { 11 12pinMode (A0, OUTPUT); // Set Arduino board analog pins to output 13digitalWrite (A0, HIGH); 14pinMode (A1, OUTPUT); 15digitalWrite (A1, HIGH); 16pinMode (A2, OUTPUT); 17digitalWrite (A2, HIGH); 18pinMode (A3, OUTPUT); 19digitalWrite (A3, HIGH); 20pinMode (A4, OUTPUT); 21digitalWrite (A4, HIGH); 22pinMode (A5, OUTPUT); 23digitalWrite (A5, HIGH); 24pinMode (A6, OUTPUT); 25digitalWrite (A6, HIGH); 26pinMode (A7, OUTPUT); 27digitalWrite (A7, HIGH); 28pinMode (A8, OUTPUT); 29digitalWrite (A8, HIGH); 30pinMode (A9, OUTPUT); 31digitalWrite (A9, HIGH); 32pinMode (A10, OUTPUT); 33digitalWrite (A10, HIGH); 34pinMode (A11, OUTPUT); 35digitalWrite (A11, HIGH); 36pinMode (A12, OUTPUT); 37digitalWrite (A12, HIGH); 38pinMode (A13, OUTPUT); 39digitalWrite (A13, HIGH); 40pinMode (A14, OUTPUT); 41digitalWrite (A14, HIGH); 42pinMode (A15, OUTPUT); 43digitalWrite (A15, HIGH); 44 45 46 47 for (int a=2; a<54; a++) 48{ 49pinMode (a, OUTPUT); // Set Arduino board digital pins to output 50digitalWrite (a, HIGH); // Set Arduino board digitsl pins to KIGH 51 52} 53 54 55// self-test 56 for (int a=14; a<36; a++) 57{ 58digitalWrite (a, LOW); // Set Arduino board digital pins to HIGH 59delay(250); 60digitalWrite (a, HIGH); // Set Arduino board digital pins to LOW 61delay(50); 62} 63 64 65 66 67 68 69 70 71 72 MIDI.begin(MIDI_CHANNEL_OMNI); // Initialize the Midi Library. 73 // OMNI sets it to listen to all channels.. MIDI.begin(2) would set it 74 // to respond to notes on channel 2 only. 75 MIDI.setHandleNoteOn(MyHandleNoteOn); // This is important!! This command 76 // tells the Midi Library which function you want to call when a NOTE ON command 77 // is received. In this case it's "MyHandleNoteOn". 78 MIDI.setHandleNoteOff(MyHandleNoteOff); // This command tells the Midi Library 79 // to call "MyHandleNoteOff" when a NOTE OFF command is received. 80} 81 82void loop() { // Main loop 83 MIDI.read(); // Continuously check if Midi data has been received. 84} 85 86// MyHandleNoteON is the function that will be called by the Midi Library 87// when a MIDI NOTE ON message is received. 88// It will be passed bytes for Channel, Pitch, and Velocity 89void MyHandleNoteOn(byte channel, byte pitch, byte velocity) { 90 switch (pitch) { 91 case 54+34: 92 digitalWrite (A0, LOW); 93 break; 94 case 55+34: 95 digitalWrite (A1, LOW); 96 break; 97 case 56+34: 98 digitalWrite (A2, LOW); 99 break; 100 case 57+34: 101 digitalWrite (A3, LOW); 102 break; 103 case 58+34: 104 digitalWrite (A4, LOW); 105 break; 106 case 59+34: 107 digitalWrite (A5, LOW); 108 break; 109 case 60+34: 110 digitalWrite (A6, LOW); 111 break; 112 case 61+34: 113 digitalWrite (A7, LOW); 114 break; 115 case 62+34: 116 digitalWrite (A8, LOW); 117 break; 118 case 63+34: 119 digitalWrite (A9, LOW); 120 break; 121 case 64+34: 122 digitalWrite (A10, LOW); 123 break; 124 case 65+34: 125 digitalWrite (A11, LOW); 126 break; 127 case 66+34: 128 digitalWrite (A12, LOW); 129 break; 130 case 67+34: 131 digitalWrite (A13, LOW); 132 break; 133 case 68+34: 134 digitalWrite (A14, LOW); 135 break; 136 case 69+34: 137 digitalWrite (A15, LOW); 138 break; 139 140 141 default: 142 // if nothing else matches, do the default 143 // default is optional 144 break; 145} 146 for (int a=2; a<54; a++) 147{ 148 if (pitch == 34+a) { 149digitalWrite (a, LOW); // Set Arduino board pin 13 to output 150 } 151} 152 153 154 155 156} 157 158// MyHandleNoteOFF is the function that will be called by the Midi Library 159// when a MIDI NOTE OFF message is received. 160// * A NOTE ON message with Velocity = 0 will be treated as a NOTE OFF message * 161// It will be passed bytes for Channel, Pitch, and Velocity 162void MyHandleNoteOff(byte channel, byte pitch, byte velocity) { 163 switch (pitch) { 164 case 54+34: 165 digitalWrite (A0, HIGH); 166 break; 167 case 55+34: 168 digitalWrite (A1, HIGH); 169 break; 170 case 56+34: 171 digitalWrite (A2, HIGH); 172 break; 173 case 57+34: 174 digitalWrite (A3, HIGH); 175 break; 176 case 58+34: 177 digitalWrite (A4, HIGH); 178 break; 179 case 59+34: 180 digitalWrite (A5, HIGH); 181 break; 182 case 60+34: 183 digitalWrite (A6, HIGH); 184 break; 185 case 61+34: 186 digitalWrite (A7, HIGH); 187 break; 188 case 62+34: 189 digitalWrite (A8, HIGH); 190 break; 191 case 63+34: 192 digitalWrite (A9, HIGH); 193 break; 194 case 64+34: 195 digitalWrite (A10, HIGH); 196 break; 197 case 65+34: 198 digitalWrite (A11, HIGH); 199 break; 200 case 66+34: 201 digitalWrite (A12, HIGH); 202 break; 203 case 67+34: 204 digitalWrite (A13, HIGH); 205 break; 206 case 68+34: 207 digitalWrite (A14, HIGH); 208 break; 209 case 69+34: 210 digitalWrite (A15, HIGH); 211 break; 212 213 214 default: 215 // if nothing else matches, do the default 216 // default is optional 217 break; 218} 219 220 for (int a=2; a<54; a++) 221{ 222 if (pitch == 34+a) { 223digitalWrite (a, HIGH); // Set Arduino board pin 13 to output 224 } 225} 226 227 228}
Downloadable files
Viev
Viev

Viev
Viev

Comments
Only logged in users can leave comments