{"id":16528,"date":"2022-10-26T23:14:41","date_gmt":"2022-10-27T03:14:41","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/?p=16528"},"modified":"2022-10-26T23:42:56","modified_gmt":"2022-10-27T03:42:56","slug":"mini-controller","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/mini-controller\/","title":{"rendered":"MINI Controller"},"content":{"rendered":"<h1><\/h1>\n<p>By Harry Schneider<\/p>\n<h4>Description:<\/h4>\n<p>The MINI controller is a compact and portable MIDI controller which allows you to produce music more efficiently.<\/p>\n<h4>Discussion:<\/h4>\n<p>Overall, I am very happy with how this project turned out. I am very pleased with the build quality despite it being my first time 3D printing. Also I think the size and overall durability is great. My goal was to make something that, if manufactured, I would personally purchase and use. Maybe I am just overly critical but I would have liked to go smaller if possible. The current size is 3 x 3 inches but I would love if it could fit comfortably in my pocket. The current size was already a challenge for me. It was very hard to fit all of the electronics inside especially with the usb input attachment. This attachment came with a large cable that took up a lot of space on the inside. In the future I would like to make another version which would have a USB type C input instead of type B. Type C is much smaller and more compatible with current technology. Also I would make it around 2 inches by 2 inches instead of 3 inches. In addition I would also make it slimmer. I found the 3D printing process to be really fun. It was very difficult designing everything in cad but with the help of my teacher I was able to actualize the case for the midi controller.<br \/>\nI was very happy with the feedback from my critique. However I was told to consider labeling the functions of the potentiometers. I understand how this makes sense but in reality, the assignments of the knobs change depending on how I intend to use them. Also it was suggested that I could use a micro Arduino if I wanted to go smaller. I will definitely use a smaller Arduino in the future. I think this was really great feedback.<\/p>\n<p>&nbsp;<\/p>\n<h3>Photos and Videos<\/h3>\n<p>Process<\/p>\n<div id=\"attachment_16548\" style=\"width: 630px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-16548\" loading=\"lazy\" class=\"wp-image-16548 size-large\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_1578-1024x768.jpg\" alt=\"\" width=\"620\" height=\"465\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_1578-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_1578-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_1578-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_1578-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_1578-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_1578-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_1578-508x381.jpg 508w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><p id=\"caption-attachment-16548\" class=\"wp-caption-text\">This is the initial working prototype. At this point the code was working properly and all of the components where working on the breadboard. At this point I was designing the case where I needed to fit these components and I had to measure everything in order to create an accurate 3D model.<\/p><\/div>\n<p>3D Modeling<\/p>\n<div id=\"attachment_16550\" style=\"width: 630px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-16550\" loading=\"lazy\" class=\"wp-image-16550 size-large\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-26-at-11.02.36-PM-1024x724.png\" alt=\"\" width=\"620\" height=\"438\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-26-at-11.02.36-PM-1024x724.png 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-26-at-11.02.36-PM-300x212.png 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-26-at-11.02.36-PM-768x543.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-26-at-11.02.36-PM-973x688.png 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-26-at-11.02.36-PM-508x359.png 508w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-26-at-11.02.36-PM.png 1248w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><p id=\"caption-attachment-16550\" class=\"wp-caption-text\">After assembling the prototype, I created the case in cad, a 2 piece design with a bottom plate with screw holes as well as a 3D printed shell.<\/p><\/div>\n<div id=\"attachment_16551\" style=\"width: 630px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-16551\" loading=\"lazy\" class=\"size-large wp-image-16551\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_1679-768x1024.jpg\" alt=\"\" width=\"620\" height=\"827\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_1679-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_1679-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_1679-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_1679-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_1679-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_1679-508x677.jpg 508w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_1679-scaled.jpg 1920w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><p id=\"caption-attachment-16551\" class=\"wp-caption-text\">These are the electronics soldered together in a way to maximize internal space<\/p><\/div>\n<div id=\"attachment_16552\" style=\"width: 630px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-16552\" loading=\"lazy\" class=\"wp-image-16552 size-large\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_1680-768x1024.jpg\" alt=\"\" width=\"620\" height=\"827\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_1680-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_1680-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_1680-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_1680-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_1680-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_1680-508x677.jpg 508w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_1680-scaled.jpg 1920w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><p id=\"caption-attachment-16552\" class=\"wp-caption-text\">This image shows how everything fits together in the 3D printed case. This part was a challenge and I was worried about everything fitting and at a point I was considering remaking the 3d model by making it bigger but I really wanted to keep it as small as possible. I decided to re-solder everything in a way that I could fit everything. I decided to use a flexible protoboard which I cut down in size to maximize as much space as possible<\/p><\/div>\n<div style=\"width: 620px;\" class=\"wp-video\"><!--[if lt IE 9]><script>document.createElement('video');<\/script><![endif]-->\n<video class=\"wp-video-shortcode\" id=\"video-16528-1\" width=\"620\" height=\"349\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_1702-2-1.mp4?_=1\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_1702-2-1.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_1702-2-1.mp4<\/a><\/video><\/div>\n<h4>Schematic<\/h4>\n<div id=\"attachment_16560\" style=\"width: 752px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-16560\" loading=\"lazy\" class=\"wp-image-16560 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Project-2-Schematic.jpg\" alt=\"\" width=\"742\" height=\"712\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Project-2-Schematic.jpg 742w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Project-2-Schematic-300x288.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Project-2-Schematic-508x487.jpg 508w\" sizes=\"(max-width: 742px) 100vw, 742px\" \/><p id=\"caption-attachment-16560\" class=\"wp-caption-text\">Schematic<\/p><\/div>\n<h4>Block Diagram<\/h4>\n<div id=\"attachment_16561\" style=\"width: 551px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-16561\" loading=\"lazy\" class=\"wp-image-16561 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Project-2-Sketches.jpg\" alt=\"\" width=\"541\" height=\"611\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Project-2-Sketches.jpg 541w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Project-2-Sketches-266x300.jpg 266w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Project-2-Sketches-508x574.jpg 508w\" sizes=\"(max-width: 541px) 100vw, 541px\" \/><p id=\"caption-attachment-16561\" class=\"wp-caption-text\">Functional block diagram<\/p><\/div>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\">\/*\r\n Harry Schneider: MINI Controller\r\n Adapted from code for midi potentiometers from Gustavo Silviera Aka \"Nerd musician\" on youtube (http:\/\/www.youtube.com\/musiconerd)\r\n*\/\r\n\r\n#define ATMEGA32U4 1\r\n#ifdef ATMEGA328\r\n#include &lt;MIDI.h&gt;\r\n#elif ATMEGA32U4\r\n#include \"MIDIUSB.h\"\r\n#endif\r\n\r\nconst int N_POTS = 4; \/\/ total numbers of pots\r\nconst int POT_ARDUINO_PIN[N_POTS] = {A0, A1, A2, A3};\r\n\r\nint potCState[N_POTS] = {0}; \/\/ Current state of the pot\r\nint potPState[N_POTS] = {0}; \/\/ Previous state of the pot\r\nint potVar = 0; \/\/ Difference between the current and previous state of the pot\r\n\r\nint midiCState[N_POTS] = {0}; \/\/ Current state of the midi value\r\nint midiPState[N_POTS] = {0}; \/\/ Previous state of the midi value\r\n\r\nconst int TIMEOUT = 300; \/\/ Amount of time the potentiometer will be read after it exceeds the varThreshold\r\nconst int varThreshold = 10; \/\/ Threshold for the potentiometer signal variation\r\nboolean potMoving = true; \/\/ If the potentiometer is moving\r\nunsigned long PTime[N_POTS] = {0}; \/\/ Previously stored time\r\nunsigned long timer[N_POTS] = {0}; \/\/ Stores the time that has elapsed since the timer was reset\r\n\r\n\/\/ MIDI\r\nbyte midiCh = 0; \/\/ MIDI channel to be used\r\nbyte note = 36; \/\/ Lowest note to be used\r\nbyte cc = 1; \/\/ Lowest MIDI CC to be used\r\n\r\n\/\/ SETUP\r\nvoid setup() {\r\n\r\n  Serial.begin(115200);\r\n\r\n#ifdef DEBUG\r\n  Serial.println(\"Debug mode\");\r\n  Serial.println();\r\n#endif\r\n}\r\n\r\n#ifdef pin13\r\nif (i == pin13index) {\r\n  buttonCState[i] = !buttonCState[i]; \/\/ inverts the pin 13 because it has a pull down resistor instead of a pull up\r\n}\r\n#endif\r\n\r\n\/\/ Sends the MIDI note ON accordingly to the chosen board\r\n#ifdef ATMEGA328\r\n\/\/ use if using with ATmega328 (uno, mega, nano...)\r\nMIDI.sendNoteOn(note + i, 127, midiCh); \/\/ note, velocity, channel\r\n\r\n#elif ATMEGA32U4\r\n\/\/ use if using with ATmega32U4 (micro, pro micro, leonardo...)\r\n\r\n#elif TEENSY\r\n\/\/do usbMIDI.sendNoteOn if using with Teensy\r\nusbMIDI.sendNoteOn(note + i, 127, midiCh); \/\/ note, velocity, channel\r\n\r\n#elif DEBUG\r\nSerial.print(i);\r\nSerial.println(\": button on\");\r\n#endif\r\n\r\n\/\/ Sends the MIDI note OFF accordingly to the chosen board\r\n#ifdef ATMEGA328\r\n\/\/ use if using with ATmega328 (uno, mega, nano...)\r\nMIDI.sendNoteOn(note + i, 0, midiCh); \/\/ note, velocity, channel\r\n\r\n#elif ATMEGA32U4\r\n\/\/ use if using with ATmega32U4 (micro, pro micro, leonardo...)\r\n\r\n#elif TEENSY\r\n\/\/do usbMIDI.sendNoteOn if using with Teensy\r\nusbMIDI.sendNoteOn(note + i, 0, midiCh); \/\/ note, velocity, channel\r\n\r\n#elif DEBUG\r\nSerial.print(i);\r\nSerial.println(\": button off\");\r\n#endif\r\n\r\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\n\/\/ POTENTIOMETERS\r\nvoid potentiometers() {\r\n\r\n\r\n  for (int i = 0; i &lt; N_POTS; i++) { \/\/ Loops through all the potentiometers\r\n\r\n    potCState[i] = analogRead(POT_ARDUINO_PIN[i]); \/\/ reads the pins from arduino\r\n\r\n    midiCState[i] = map(potCState[i], 0, 1023, 0, 127); \/\/ Maps the reading of the potCState to a value usable in midi\r\n\r\n    potVar = abs(potCState[i] - potPState[i]); \/\/ Calculates the absolute value between the difference between the current and previous state of the pot\r\n\r\n    if (potVar &gt; varThreshold) { \/\/ Opens the gate if the potentiometer variation is greater than the threshold\r\n      PTime[i] = millis(); \/\/ Stores the previous time\r\n    }\r\n\r\n    timer[i] = millis() - PTime[i]; \/\/ Resets the timer 11000 - 11000 = 0ms\r\n\r\n    if (timer[i] &lt; TIMEOUT) {\r\n      potMoving = true;\r\n    }\r\n    else {\r\n      potMoving = false;\r\n    }\r\n\r\n    if (potMoving == true) { \/\/ If the potentiometer is still moving, send the change control\r\n      if (midiPState[i] != midiCState[i]) {\r\n\r\n        \/\/ Sends the MIDI CC accordingly to the chosen board\r\n#ifdef ATMEGA328\r\n        MIDI.sendControlChange(cc + i, midiCState[i], midiCh); \/\/ cc number, cc value, midi channel\r\n\r\n#elif ATMEGA32U4\r\n\r\n        controlChange(midiCh, cc + i, midiCState[i]); \/\/\r\n        MidiUSB.flush();\r\n\r\n#elif TEENSY\r\n        usbMIDI.sendControlChange(cc + i, midiCState[i], midiCh); \/\/ cc number, cc value, midi channel\r\n\r\n#elif DEBUG\r\n        Serial.print(\"Pot: \");\r\n        Serial.print(i);\r\n        Serial.print(\" \");\r\n        Serial.println(midiCState[i]);\r\n        \/\/Serial.print(\"  \");\r\n#endif\r\n\r\n        potPState[i] = potCState[i]; \/\/ Stores the current reading of the potentiometer to compare with the next\r\n        midiPState[i] = midiCState[i];\r\n      }\r\n    }\r\n  }\r\n}\r\n\r\n#ifdef ATMEGA32U4\r\n\r\n\/\/ Arduino (pro)micro midi functions MIDIUSB Library\r\nvoid noteOn(byte channel, byte pitch, byte velocity) {\r\n  midiEventPacket_t noteOn = {0x09, 0x90 | channel, pitch, velocity};\r\n  MidiUSB.sendMIDI(noteOn);\r\n}\r\n\r\nvoid noteOff(byte channel, byte pitch, byte velocity) {\r\n  midiEventPacket_t noteOff = {0x08, 0x80 | channel, pitch, velocity};\r\n  MidiUSB.sendMIDI(noteOff);\r\n}\r\n\r\nvoid controlChange(byte channel, byte control, byte value) {\r\n  midiEventPacket_t event = {0x0B, 0xB0 | channel, control, value};\r\n  MidiUSB.sendMIDI(event);\r\n}\r\n#endif<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By Harry Schneider Description: The MINI controller is a compact and portable MIDI controller which allows you to produce music more efficiently. Discussion: Overall, I am very happy&#8230;<\/p>\n","protected":false},"author":225,"featured_media":16531,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[89],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-json\/wp\/v2\/posts\/16528"}],"collection":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-json\/wp\/v2\/users\/225"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-json\/wp\/v2\/comments?post=16528"}],"version-history":[{"count":7,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-json\/wp\/v2\/posts\/16528\/revisions"}],"predecessor-version":[{"id":16569,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-json\/wp\/v2\/posts\/16528\/revisions\/16569"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-json\/wp\/v2\/media\/16531"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-json\/wp\/v2\/media?parent=16528"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-json\/wp\/v2\/categories?post=16528"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-json\/wp\/v2\/tags?post=16528"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}