{"id":14438,"date":"2021-11-02T09:00:03","date_gmt":"2021-11-02T13:00:03","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/?p=14438"},"modified":"2021-11-02T09:18:55","modified_gmt":"2021-11-02T13:18:55","slug":"accessory-keyboard","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/accessory-keyboard\/","title":{"rendered":"Accessory Keyboard"},"content":{"rendered":"<p>An handy set of programmable keys to keep your most used functions within reach.<\/p>\n<h2>Photos:<\/h2>\n<div id=\"attachment_14489\" style=\"width: 610px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-14489\" loading=\"lazy\" class=\"wp-image-14489 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/ezgif-2-76b36e67cfb1.gif\" alt=\"\" width=\"600\" height=\"338\" \/><p id=\"caption-attachment-14489\" class=\"wp-caption-text\">Standard use, first four keys 1-4, 5th key mapped to long message<\/p><\/div>\n<div id=\"attachment_14490\" style=\"width: 1930px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-14490\" loading=\"lazy\" class=\"wp-image-14490 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_083823-scaled.jpg\" alt=\"\" width=\"1920\" height=\"2560\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_083823-scaled.jpg 1920w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_083823-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_083823-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_083823-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_083823-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_083823-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_083823-508x677.jpg 508w\" sizes=\"(max-width: 1920px) 100vw, 1920px\" \/><p id=\"caption-attachment-14490\" class=\"wp-caption-text\">A cinematic view with plants!<\/p><\/div>\n<div id=\"attachment_14502\" style=\"width: 630px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-14502\" loading=\"lazy\" class=\"wp-image-14502 size-large\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_084231-768x1024.jpg\" alt=\"\" width=\"620\" height=\"827\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_084231-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_084231-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_084231-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_084231-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_084231-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_084231-508x677.jpg 508w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_084231-scaled.jpg 1920w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><p id=\"caption-attachment-14502\" class=\"wp-caption-text\">Next to a tape measure for scale<\/p><\/div>\n<div id=\"attachment_14495\" style=\"width: 630px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-14495\" loading=\"lazy\" class=\"wp-image-14495 size-large\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_083848-1024x768.jpg\" alt=\"\" width=\"620\" height=\"465\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_083848-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_083848-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_083848-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_083848-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_083848-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_083848-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_083848-508x381.jpg 508w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><p id=\"caption-attachment-14495\" class=\"wp-caption-text\">A top down view of the layout<\/p><\/div>\n<div id=\"attachment_14508\" style=\"width: 630px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-14508\" loading=\"lazy\" class=\"wp-image-14508 size-large\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_085352-scaled-e1635857905387-1024x768.jpg\" alt=\"\" width=\"620\" height=\"465\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_085352-scaled-e1635857905387-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_085352-scaled-e1635857905387-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_085352-scaled-e1635857905387-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_085352-scaled-e1635857905387-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_085352-scaled-e1635857905387-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_085352-scaled-e1635857905387-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_085352-scaled-e1635857905387-508x381.jpg 508w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><p id=\"caption-attachment-14508\" class=\"wp-caption-text\">A use case example. On a desktop as shortcut keys.<\/p><\/div>\n<h2>Process Photos:<\/h2>\n<div id=\"attachment_14517\" style=\"width: 630px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-14517\" loading=\"lazy\" class=\"wp-image-14517 size-large\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211025_063400-1024x768.jpg\" alt=\"\" width=\"620\" height=\"465\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211025_063400-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211025_063400-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211025_063400-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211025_063400-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211025_063400-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211025_063400-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211025_063400-508x381.jpg 508w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><p id=\"caption-attachment-14517\" class=\"wp-caption-text\">early component testing, including a mess of wires, resistors, and eraser shavings<\/p><\/div>\n<div id=\"attachment_14519\" style=\"width: 630px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-14519\" loading=\"lazy\" class=\"wp-image-14519 size-large\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_090903_2-853x1024.jpg\" alt=\"\" width=\"620\" height=\"744\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_090903_2-853x1024.jpg 853w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_090903_2-250x300.jpg 250w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_090903_2-768x922.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_090903_2-1280x1536.jpg 1280w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_090903_2-1706x2048.jpg 1706w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_090903_2-973x1168.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_090903_2-508x610.jpg 508w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><p id=\"caption-attachment-14519\" class=\"wp-caption-text\">Initial ideation, input and format brainstorming<\/p><\/div>\n<div id=\"attachment_14520\" style=\"width: 630px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-14520\" loading=\"lazy\" class=\"wp-image-14520 size-large\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/Copy-of-MVIMG_20211102_090853_2-923x1024.jpg\" alt=\"\" width=\"620\" height=\"688\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/Copy-of-MVIMG_20211102_090853_2-923x1024.jpg 923w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/Copy-of-MVIMG_20211102_090853_2-270x300.jpg 270w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/Copy-of-MVIMG_20211102_090853_2-768x852.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/Copy-of-MVIMG_20211102_090853_2-1385x1536.jpg 1385w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/Copy-of-MVIMG_20211102_090853_2-1846x2048.jpg 1846w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/Copy-of-MVIMG_20211102_090853_2-973x1079.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/Copy-of-MVIMG_20211102_090853_2-508x563.jpg 508w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><p id=\"caption-attachment-14520\" class=\"wp-caption-text\">struggling to portion out inputs and understanding requirements<\/p><\/div>\n<h2>Decision Points:<\/h2>\n<div id=\"attachment_14498\" style=\"width: 630px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-14498\" loading=\"lazy\" class=\"wp-image-14498 size-large\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_084035-1024x768.jpg\" alt=\"\" width=\"620\" height=\"465\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_084035-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_084035-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_084035-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_084035-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_084035-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_084035-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/MVIMG_20211102_084035-508x381.jpg 508w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><p id=\"caption-attachment-14498\" class=\"wp-caption-text\">A clear view of the wiring matrix and efficiently used potentiometer power and ground<\/p><\/div>\n<p>Wiring Strategy<\/p>\n<p>A critical consideration when designing a custom keyboard is wiring. This was an unexpected step which affected far more than I thought it could. The Arduino pro micro is an exceptional piece of technology, but is only built to handle so many inputs. This has led enthusiasts the apply creative workarounds and allowed them to achieve exceptional results. The critical option for me was individually wiring each switch or forming them in an array and addressing the problem of ghosting with diodes. Individual wiring would be far more messy and setting up buttons in a matrix was generally the practice in most custom boards. I decided to hand wire a neat matrix and follow the steps someone might use for a much larger keyboard to further immerse myself in the learning process. With careful wire stripping and many soldering attempts, I was able to neatly lay out the matrix for eight switch inputs.<\/p>\n<div id=\"attachment_14510\" style=\"width: 810px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-14510\" loading=\"lazy\" class=\"wp-image-14510 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/Capture-1.png\" alt=\"\" width=\"800\" height=\"695\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/Capture-1.png 800w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/Capture-1-300x261.png 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/Capture-1-768x667.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/Capture-1-508x441.png 508w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><p id=\"caption-attachment-14510\" class=\"wp-caption-text\">notoriously buggy flashing software<\/p><\/div>\n<div id=\"attachment_14509\" style=\"width: 870px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-14509\" loading=\"lazy\" class=\"wp-image-14509 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/Capture1.png\" alt=\"\" width=\"860\" height=\"438\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/Capture1.png 860w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/Capture1-300x153.png 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/Capture1-768x391.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/Capture1-508x259.png 508w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><p id=\"caption-attachment-14509\" class=\"wp-caption-text\">guide for wiring, showing example of for a &#8216;plank&#8217; layout<\/p><\/div>\n<p>&nbsp;<\/p>\n<p>HID vs Arduino<\/p>\n<p>When sending signals from the Arduino to the computer there are two ways the computer can read them; as input from an Arduino device that needs to be translated, or as native keyboard inputs from an HID. Following the spirit of a fully native keyboard, I attempted to flash my Arduino pro micro using community developed tools. The process of flashing skips over the step where a computer has to read a device as an Arduino before receiving simulated keyboard inputs and would hopefully lead to a more robust tool. This option included several external programs to feed matrix diagrams into very abstract code. Ultimately, despite investing my efforts into this step in order to make a native keyboard device very specific issues, such as a missing .dll file that affected how my computer&#8217;s USB port communication left me with software issues I could not understand well enough to fix. I was forced to keep the traditional Arduino input<\/p>\n<h2>Discussion:<\/h2>\n<p><span style=\"font-weight: 400\">The construction of a macro keyboard was an insightful and difficult experience in developing a useful tool tailored for myself. By diving into a expansive hobby I learned from a massive array of disciplines and got to understand, first hand, the potentials and difficulties of building and programming a custom keyboard. Fundamentally, the project can be split into hardware and software.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">The hardware component of the experience was significantly more creative and forgiving. Classmate responses noted \u201c&#8230;the physical customization of a keyboard\u2026 shows how creative you can be with something that seems really standard.\u201d I felt this was a perfect interpretation of my ideation stage, which saw me find all the possible inputs I could use without writing new fundamental components, like libraries. Unfortunately, my inexperience led to some hardware choices which, in retrospect, were not ideal. This is exemplified by my choice of a potentiometer instead of a rotary encoder. While the potentiometer worked well for volume control, a hardware item with a physical upper and lower limit was not as easy to apply to common computer programs as would have been a simple increase-decrease input (rotary encoder). This taught me that when designing a versatile tool, the more open ended and simple the inputs, the more use it will be.<\/span><\/p>\n<p><span style=\"font-weight: 400\">A less functional, but still incredibly important aspect of the project is the design. A big motivation between custom keyboards is personalization. One classmate wrote \u201c<\/span><span style=\"font-weight: 400\">I like how clean the keypad looks with the acrylic base and it\u2019s really nice how you hand-wired everything.\u201d This comment made me very excited to see other people finding joy in customizing something so mundane. <\/span><span style=\"font-weight: 400\">Through the project I learned about popular styles and where enthusiasts found beauty in electrical tools like keyboards. Hand-wiring and efficiency were popular themes that I subscribed to. Gridded geometric wiring, clear casing, and colorful keycaps were my adoption of the popular design principles in custom keyboards.<\/span><\/p>\n<p><span style=\"font-weight: 400\">The software portion of the project was much more rigid and problematic. Here, roadblocks presented themselves left and right, from out of date tools to nuanced device issues. While there was a breadth of experience available, the lack of a single popular resource meant many uncommon issues remained unsolved. Other project documentation often warned of numerous attempts to get fundamental functionality.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Future iterations are all but set in stone. The giant variety of formats and the fact that I will probably use a keyboard every day for the rest of my life assures me this is not a learning experience I am done with. Layered cases, greater quantity of inputs, more complex inputs, even designing a marketable product are within the range of possibility.<\/span><\/p>\n<h2>Block Diagram:<\/h2>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-14444\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/diagramsvgp2.svg\" alt=\"\" width=\"957\" height=\"1412\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2>Schematic Diagram:<\/h2>\n<h2><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/p2elecd.svg\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-14443\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-content\/uploads\/2021\/11\/p2elecd.svg\" alt=\"\" width=\"1451\" height=\"522\" \/><\/a><\/h2>\n<h2>Code:<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">\/\/Accessory Keyboard\r\n\/\/The code maps the matrix wired into columns and rows to output keys or packets of information. It also attempts to create layers by taking advantage of arduino's capabilities over a traditional keyboard. Unforunately, this portion was not properly impletmented.\r\n\/\/The matrix assigns columns to pins 6, 7, 8, and 9. Rows are assigned to pins 4 and 5.\r\n\/\/The code borrows heavily from creators who have tried to execute similar projects and smaller projects that do fewer functions.\r\n\/\/https:\/\/create.arduino.cc\/projecthub\/Arnov_Sharma_makes\/hid-volume-knob-with-pro-micro-db0bf8 by Arnov Sharma\r\n\/\/https:\/\/www.instructables.com\/Programmable-Macropad-V2\/ by tinyboatproductions\r\n\r\n#include &lt;Keypad.h&gt;\r\n#include &lt;Encoder.h&gt;\r\n#include &lt;Bounce2.h&gt;\r\n#include \"HID-Project.h\"\r\n\/\/The required libraries that simulate keyboard inputs\r\n\/\/Keypad buttons\r\nint R1 = 4;\r\nint R2 = 5;\r\nint C1 = 6;\r\nint C2 = 7;\r\nint C3 = 8;\r\nint C4 = 9;\r\n\/\/Necessary arrangement to help orient ourselves when receiving input\r\nconst byte ROWS = 2;\r\nconst byte COLS = 4;\r\nchar keys[COLS][ROWS] = {\r\n  {'4','8'},\r\n  {'3','7'},\r\n  {'2','6'},\r\n  {'1','5'}\r\n};\r\nbyte rowPins[ROWS] = {R1, R2};\r\nbyte colPins[COLS] = {C1, C2, C3, C4};\r\nKeypad kpd = Keypad( makeKeymap(keys), colPins, rowPins, COLS, ROWS);\r\n\r\n\/\/ Unused code to allow for variable inputs based on unintegrated magnet switch\r\nint S1 = 15;\r\nint S2 = 14;\r\nconst int numStates = 2;\r\nconst int States[numStates] = {S1, S2};\r\nint currentState = 0;\r\n\r\nint lastDebounceTime = 0;\r\nconst int debounceTime = 50;\r\n\r\nvoid setup() {\r\n  Serial.begin(9600);\r\n\r\n  for (int i = 0; i &lt; numStates; i++){\r\n    pinMode(States[i], OUTPUT);\r\n    digitalWrite(States[i], LOW);\r\n  }\r\n  \r\n  Keyboard.begin();\r\n}\r\n\r\n\/\/Borrowed code that helps tell the arduino which state it is in. Also unused as only one state stays active.\r\nvoid ChangeState(){\r\n  digitalWrite(States[currentState], LOW);\r\n  currentState++;\r\n  if (currentState == numStates){\r\n    currentState = 0;\r\n  }\r\n  digitalWrite(States[currentState], HIGH);\r\n  delay(100);\r\n  return;\r\n}\r\n\r\n\/\/ The first layout that can assign the 8 switch buttons to any keyboard output, or combination thereof. Note key 5 outputs a text packet.\r\nvoid Layout1(char button){\r\n  switch(button){\r\n    case '1':\r\n      Keyboard.print(\"1\");\r\n      break;\r\n    case '2':\r\n      Keyboard.print('2');\r\n      break;\r\n    case '3':\r\n      Keyboard.print('3');\r\n      break;\r\n    case '4':\r\n      Keyboard.print('4');\r\n      break;\r\n    case '5':\r\n      Keyboard.print(\"Did you ever hear the tragedy of Darth Plagueis The Wise? I thought not. It\u2019s not a story the Jedi would tell you. It\u2019s a Sith legend. Darth Plagueis was a Dark Lord of the Sith, so powerful and so wise he could use the Force to influence the midichlorians to create life\u2026 He had such a knowledge of the dark side that he could even keep the ones he cared about from dying. The dark side of the Force is a pathway to many abilities some consider to be unnatural. He became so powerful\u2026 the only thing he was afraid of was losing his power, which eventually, of course, he did. Unfortunately, he taught his apprentice everything he knew, then his apprentice killed him in his sleep. Ironic. He could save others from death, but not himself.\");\r\n      break;\r\n    case '6':\r\n      Keyboard.print('6');\r\n      break;\r\n    case '7':\r\n      Keyboard.print('7');\r\n      break;\r\n    case '8':\r\n      Keyboard.print('8');\r\n      break;\r\n    case '9':\r\n      Keyboard.print('9');\r\n      break;\r\n  };\r\n}\r\nvoid Layout2(char button){\r\n  switch(button){\r\n    case '1':\/\/\r\n      break;\r\n    case '2':\/\/\r\n      break;\r\n    case '3':\/\/\r\n      break;\r\n    case '4':\/\/\r\n      break;\r\n    case '5':\/\/\r\n      break;\r\n    case '6':\/\/Return\r\n      Keyboard.press(KEY_RETURN);\r\n      Keyboard.releaseAll();\r\n      break;\r\n    case '7':\/\/Escape\r\n      Keyboard.press(KEY_ESC);\r\n      Keyboard.releaseAll();\r\n      break;\r\n    case '8':\/\/\r\n      break;\r\n    case '9':\/\/\r\n      break;\r\n  };\r\n}\r\nvoid loop() {\r\n  \/\/check the key matrix first\r\n  char key = kpd.getKey();\r\n  if(key) {\r\n    switch(key){\r\n      case '*':\r\n        ChangeState();\r\n        break;\r\n      case '-':\r\n        Keyboard.press(KEY_RIGHT_CTRL);\r\n        Keyboard.press('s');\r\n        delay(10);\r\n        Keyboard.releaseAll();\r\n        break;\r\n      default:\r\n        switch(currentState){\r\n          case 0:\r\n            Layout1(key);\r\n            break;\r\n          case 1:\r\n            Layout2(key);\r\n            break;\r\n        }\r\n    }\r\n  }<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>An handy set of programmable keys to keep your most used functions within reach. Photos: Process Photos: Decision Points: Wiring Strategy A critical consideration when designing a custom&#8230;<\/p>\n","protected":false},"author":205,"featured_media":14490,"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\/f2021\/work\/wp-json\/wp\/v2\/posts\/14438"}],"collection":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-json\/wp\/v2\/users\/205"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-json\/wp\/v2\/comments?post=14438"}],"version-history":[{"count":6,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-json\/wp\/v2\/posts\/14438\/revisions"}],"predecessor-version":[{"id":14522,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-json\/wp\/v2\/posts\/14438\/revisions\/14522"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-json\/wp\/v2\/media\/14490"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-json\/wp\/v2\/media?parent=14438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-json\/wp\/v2\/categories?post=14438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2021\/work\/wp-json\/wp\/v2\/tags?post=14438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}