MIDI+Arduino Trigger
MIDI+Arduino project gives you a physical MIDI or MSC trigger button.
Arduino Code:
// MSC MIDI Arduino controller
// By Dave Mickey, myMIDIremotes
int buttonPin4 = 7;
int buttonPin3 = 6;
int buttonPin2 = 5;
int buttonPin1 = 4;
int ledPinON = 2; //LED states that the code loaded correctly
int ledPinMIDI = 3; //LED states that the MIDI was sent
// variables will change:
int buttonState1 = 0;
int buttonState2 = 0;
int buttonState3 = 0;
int buttonState4 = 0;
void setup() {
Serial.begin(31250); // Set serial to the MIDI baud rate of 31250
pinMode(ledPinMIDI, OUTPUT);
pinMode(ledPinON, OUTPUT);
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, INPUT);
digitalWrite(ledPinON, HIGH);
digitalWrite(ledPinMIDI, HIGH);
delay(500);
digitalWrite(ledPinMIDI, LOW);
}
void loop() {
buttonState1 = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);
buttonState3 = digitalRead(buttonPin3);
buttonState4 = digitalRead(buttonPin4);
//MSC GO
if (buttonState3 == 0) {
//Serial.println(“MSC GO”);
digitalWrite(ledPinMIDI, HIGH);
Serial.write(0xF0);
Serial.write(0x7F);
Serial.write(0x7F); //device id 7F = 127 all channels
Serial.write(0x02);
Serial.write(0x7F); // command format 7F = all devices
Serial.write(0x01); // action 0x01 = MSC GO
Serial.write(0xF7);
delay(500);
digitalWrite(ledPinMIDI, LOW);
buttonState3 = 1;
}
// MSC STOP
if (buttonState4 == 0) {
//Serial.println(“MSC STOP”);
digitalWrite(ledPinMIDI, HIGH);
Serial.write(0xF0);
Serial.write(0x7F);
Serial.write(0x7F); //device id 7F = 127 all channels
Serial.write(0x02);
Serial.write(0x7F); // command format 7F = all devices
Serial.write(0x08); // action 0x08 = all off
Serial.write(0xF7);
delay(500);
digitalWrite(ledPinMIDI, LOW);
buttonState4 = 1;
}
// MSC NEXT
if (buttonState1 == 0) {
//Serial.println(“MSC NEXT”);
digitalWrite(ledPinMIDI, HIGH);
Serial.write(0xF0);
Serial.write(0x7F);
Serial.write(0x7F); //device id 7F = 127 all channels
Serial.write(0x02);
Serial.write(0x7F); // command format 7F = all devices
Serial.write(0x17); // action 0x17= next
Serial.write(0xF7);
delay(500);
digitalWrite(ledPinMIDI, LOW);
buttonState1 = 1;
}
// MSC RESET
if (buttonState2 == 0) {
//Serial.println(“MSC reset”);
digitalWrite(ledPinMIDI, HIGH);
Serial.write(0xF0);
Serial.write(0x7F);
Serial.write(0x7F); //device id 7F = 127 all channels
Serial.write(0x02);
Serial.write(0x7F); // command format 7F = all devices
Serial.write(0x0A); // action 0x0A= reset
Serial.write(0xF7);
delay(500);
digitalWrite(ledPinMIDI, LOW);
buttonState2 = 1;
}
//delay(2000);
}
MSC Hex Commands:
0x01 GO
0x02 STOP
0x03 RESUME
0x04 TIMED_GO
0x05 LOAD
0x06 SET
0x07 FIRE
0x08 ALL_OFF
0x09 RESTORE
0x10 0A RESET
0x11 0B GO_OFF
0x17 next
0x18 prev
command_format:
0x01 Lighting
0x02 Moving Lights
0x03 Colour Changers
0x04 Strobes
0x05 Lasers
0x06 Chasers
0x10 Sound
0x11 Music
0x12 CD Players
0x13 EPROM Playback
0x14 Audio Tape Machines
0x15 Intercoms
0x16 Amplifiers
0x17 Audio Effects Devices
0x18 Equalisers
0x20 Machinery
0x21 Rigging
0x22 Flys
0x23 Lifts
0x24 Turntables
0x25 Trusses
0x26 Robots
0x27 Animation
0x28 Floats
0x29 Breakaways
0x2A Barges
0x30 Video
0x31 Video Tape Machines
0x32 Video Cassette Machines
0x33 Video Disc Players
0x34 Video Switchers
0x35 Video Effects
0x36 Video Character Generators
0x37 Video Still Stores
0x38 Video Monitors
0x40 Projection
0x41 Film Projectors
0x42 Slide Projectors
0x43 Video Projectors
0x44 Dissolvers
0x45 Shutter Controls
0x50 Process Control
0x51 Hydraulic Oil
0x52 H20
0x53 CO2
0x54 Compressed Air
0x55 Natural Gas
0x56 Fog
0x57 Smoke
0x58 Cracked Haze
0x60 Pyro
0x61 Fireworks
0x62 Explosions
0x63 Flame
0x64 Smoke pots
0x7F All-types
To send MIDI note from Arduino:
Serial.write(0x90); // Note On
Serial.write(0x01); //Note
Serial.write(127); //Value
Hex to MIDI Commands
0x80 Note Off
0x90 Note On
0xA0 Aftertouch
0xB0 Continuous Controller
0xC0 Patch change
0xD0 Channel Pressure
0xE0 Pitch bend
Value: 0-127
Hex to MIDI Note
0-127
or
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 |
C -1 C#-1 D -1 Eb-1 E -1 F -1 F#-1 G -1 G#-1 A -1 Bb-1 B -1 C 0 C# 0 D 0 Eb 0 E 0 F 0 F# 0 G 0 G# 0 A 0 Bb 0 B 0 C 1 C# 1 D 1 Eb 1 E 1 F 1 F# 1 G 1 G# 1 A 1 Bb 1 B 1 C 2 C# 2 D 2 Eb 2 E 2 F 2 F# 2 G 2 G# 2 A 2 Bb 2 B 2 C 3 C# 3 D 3 Eb 3 E 3 F 3 F# 3 G 3 G# 3 A 3 Bb 3 B 3 C 4 C# 4 D 4 Eb 4 E 4 F 4 F# 4 G 4 G# 4 A 4 Bb 4 B 4 C 5 C# 5 D 5 Eb 5 E 5 F 5 F# 5 G 5 G# 5 A 5 Bb 5 B 5 C 6 C# 6 D 6 Eb 6 E 6 F 6 F# 6 G 6 G# 6 A 6 Bb 6 B 6 C 7 C# 7 D 7 Eb 7 E 7 F 7 F# 7 G 7 G# 7 A 7 Bb 7 B 7 C 8 C# 8 D 8 Eb 8 E 8 F 8 F# 8 G 8 G# 8 A 8 Bb 8 B 8 |