JoyStick - Creative Technical
Maybe your like
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:
joyStick /* --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); }| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 | /* --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) bytepinarray[SWITCHCOUNT]={2,3,4,5,6};byteplayarray[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 intstateUp=0;// variable for reading the pin statusintstateRight=0;intstateDown=0;intstateLeft=0;intstateButton=0;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////voidsetup(){Serial.begin(31250);// Set MIDI baud ratepinMode(PINUP,INPUT_PULLUP);// Set the switch pin as input, and enable pullup resistorpinMode(PINRIGHT,INPUT_PULLUP);pinMode(PINDOWN,INPUT_PULLUP);pinMode(PINLEFT,INPUT_PULLUP);pinMode(PINBUTTON,INPUT_PULLUP);}//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////voidloop(){for(inti=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 stateUpstateRight=digitalRead(PINRIGHT);stateDown=digitalRead(PINDOWN);stateLeft=digitalRead(PINLEFT);stateButton=digitalRead(PINBUTTON); // SendMIDI(0xB0, 123, 0); // Silence all notes //fake monosynthif(stateUp==LOW&&stateRight==LOW&&stateButton==LOW){SendMIDI(MIDICMD_NOTEON,BUTTON_UP_RIGHT_NOTE,127);}elseif(stateRight==LOW&&stateDown==LOW&&stateButton==LOW){SendMIDI(MIDICMD_NOTEON,BUTTON_DOWN_RIGHT_NOTE,127);}elseif(stateDown==LOW&&stateLeft==LOW&&stateButton==LOW){SendMIDI(MIDICMD_NOTEON,BUTTON_DOWN_LEFT_NOTE,127);}elseif(stateLeft==LOW&&stateUp==LOW&&stateButton==LOW){SendMIDI(MIDICMD_NOTEON,BUTTON_UP_LEFT_NOTE,127);}elseif(stateUp==LOW&&stateButton==LOW){SendMIDI(MIDICMD_NOTEON,BUTTON_UP_NOTE,127);}elseif(stateRight==LOW&&stateButton==LOW){SendMIDI(MIDICMD_NOTEON,BUTTON_RIGHT_NOTE,127);}elseif(stateDown==LOW&&stateButton==LOW){SendMIDI(MIDICMD_NOTEON,BUTTON_DOWN_NOTE,127);}elseif(stateLeft==LOW&&stateButton==LOW){SendMIDI(MIDICMD_NOTEON,BUTTON_LEFT_NOTE,127);}// 8 Notes code //////////////////////////////////////////////////////////////////////////////elseif(stateUp==LOW&&stateRight==LOW){SendMIDI(MIDICMD_NOTEON,UP_RIGHT_NOTE,127);}elseif(stateRight==LOW&&stateDown==LOW){SendMIDI(MIDICMD_NOTEON,DOWN_RIGHT_NOTE,127);}elseif(stateDown==LOW&&stateLeft==LOW){SendMIDI(MIDICMD_NOTEON,DOWN_LEFT_NOTE,127);}elseif(stateLeft==LOW&&stateUp==LOW){SendMIDI(MIDICMD_NOTEON,UP_LEFT_NOTE,127);}elseif(stateUp==LOW){SendMIDI(MIDICMD_NOTEON,UP_NOTE,127);}elseif(stateRight==LOW){SendMIDI(MIDICMD_NOTEON,RIGHT_NOTE,127);}elseif(stateDown==LOW){SendMIDI(MIDICMD_NOTEON,DOWN_NOTE,127);}elseif(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);}//////////////////////////////////////////////////////////////////////////////////////////////voidSendMIDI(charcmd,chardata1,chardata2)//laserharp method{Serial.print(cmd);Serial.print(data1);Serial.print(data2);} |
Tag » Arduino Midi Joystick
-
How To Use A Joystick As A MIDI Controller - Quora
-
Send Midi Pitch Bend With A Joystick - Audio - Arduino Forum
-
10 MIDI Controllers You Can Build With An Arduino - MakeUseOf
-
DART - Arduino MIDI Ontroller - Analog Joystick Used For MIDI Control.
-
Joystick – Mouse - Dart Arduino Midi Dmx Controller
-
10 Amazing DIY MIDI Controllers Made With Arduino - All3DP
-
DIY USB Midi Controller With Arduino: A Beginner's Guide
-
JoyBox_MIDI Is An Arduino Joystick MIDI Controller - GitHub
-
MIDI Transport Controller And Joystick - Amongst Myselves
-
Mua Arduino MIDI Controller Chính Hãng Giá Tốt Tháng 6, 2022
-
TheMIDInator Arduino MIDI Controller
-
Joystick MIDI-controller - Sigma
-
Dart, A Line Of Open Source MIDI And DMX Controllers, In Wonderfully ...