Arduino Pro Micro Macro Keyboard Version 2.0 | DIY Macro Pad for Professional Keyboard Slayers

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone the macro keyboard project has turned out to be pretty popular as a baseline no one watches this channel so i'm going to call this project a success as a result i've received some great feedback regarding improvements if a second version was going to be made so here's that second version this video is long and therefore it's broken up into four main segments what is a macro keyboard how to assemble this version macro examples and sprinkled about the hidden work behind this project if you want to make this you can buy this pcb using the link in the description all code examples are also linked below if this is something you're interested in why buy it when you can build it for three times the cost this project is something you can build it does require some intermediate soldering skills and you don't need to know how to program but familiarity with code will help with some of the examples and how to write your own macros speaking of building the estimated burden of cost for this is around 46 dollars for what i'm calling the pro model that's the translucent cherry keys clear or windowed keycaps rgb backlighting with an external lcd screen attached i listed the part numbers where i can find them the cost estimate does not include shipping or some parts that are only sold in bulk quantities like the rgb leds but before i get ahead of myself let's back up a bit and see how we got here now the original macro keyboard stopped at version 0.4 so if i'm showing version 2.0 then what happened to version 1.0 well it was a sort of spin-off into this mini version this mini version was a well a do-over layout-wise and the short version of this story is i just had some things that should have been fixed so i did and that brings us up to the present just to get everyone up to speed a macro keyboard is like a quality of life improvement for those of us who interface with the keyboard and various programs daily you might use a shortcut key combination or macro to accomplish tasks within your application workflow an example this is simply maybe you use copy and paste many times in a day what if you could turn that into a one key press instead of two or maybe you need to open the calculator once in a while what if we could bind the process of opening the start bar searching calc and launching that all with a single key press better yet do you ever struggle with the sequence to end a zoom call what if you could maintain strong eye contact while ending a call with a single button these multi-sequence key inputs compressed into a single key press are macros and you can program about any macro imaginable with this pcb and the arduino pro micro this keyboard also has the option to use rotary encoders which makes some tasks more intuitive like zooming in and out or for example skipping around on a timeline when editing a video like this my original macro keyboard video goes into a bit more detail on basic macros so please watch that if you're looking for more information before we showcase the new hardware let's assemble it in principle assembly is nearly identical to the previous version the keys are in a row column matrix layout 12 keys total with three rows and four columns starting from the top left to right the keys are labeled in this sequential order the schematic and code match this layout note the code maps the keys as single characters in order to make the matrix array so double digits like keys 10 11 and 12 are identified as keys 0 a and b respectively this is just a limitation of that data type input matrices like this can be prone to key ghosting if multiple keys are pressed in a local area so there is a hardware option to add a diode to each key to prevent this the diodes are really only useful if you expect to press many keys simultaneously and your code also has to have that functionality mine doesn't but from here on out the typical use for our macro keyboard is isolated single key presses that means we're not populating any of the diode components we can bypass all the individual diodes so we're going to solder the diode bypass solder jumpers for every key if you forget one of these jumpers the keyboard will function irregularly be sure to do all the diode bypass jumpers if you're not using diodes do make sure you don't solder all these solder jumpers there are two in the upper corner in particular and we'll talk about those more in a bit the rotary encoders are a nice way to smoothly trigger multiple button presses if you want to use the rotary encoders you need to solder the encoder enabled jumpers there are two for each encoder this jumper will connect the encoder lines to the pro micro by default they're disconnected a new feature on this pcb is an i squared c breakout connector for adding an external lcd this could be a 3.3 volt or 5 volt lcd or oled screen i only have this chunky 4 by 20 screen so i need to pick the correct voltage to power it through the i scored c breakout this is done by soldering only one jumper do not solder both jumpers the vcc jumper will supply 3.3 volts the regulated output for most arduino pro microboards the v-raw will supply 5 volts or whatever your usb voltage rail is for my application i am bridging the v-raw jumper as this screen needs 5 volts from the usb power rail if you're using an oled screen that needs 3.3 volts do not bridge the v-raw jumper at the time of filling this board has a silk screen error which has some overlapping callouts in this area just ignore this it's going to be fixed soonish solder in the right angle header to connect a screen as a reminder both this macro keyboard and the mini version have this selectable i scored c voltage jumper next we have a major upgrade from the previous version this was a must-have on my list and it's why this project took so long individually addressable leds but not just single color rgb leds these are sk 6812 mini e leds they are compatible with the adafruit neopixel library and the fast led library these leds are soldered to the back side of the pcb so this step can be done after you solder all the keys if you want to use your keyboard now but don't have these addressable leds yet you can skip this step and come back to it later these leds have a notch cutout that marks the ground pin the back's silk screen marks this location make sure your led has this pin out the data sheet i was using was a bit confusing it was also scanned digitally using what i guess was a potato the footprint that called out this seemed to be backwards too so what i'm saying is just check everything a few times before you solder make sure you have the right part these leds are stated to be delicate so be mindful of your iron temperature these leds should sit flush on these pads i'm going to tack them down in place in one corner and work my way around flux helps a lot here these leds are powered from v-raw which is likely going to be your usb 5-volt rail just a friendly note at max brightness with all these leds on you're going to pull a non-trivial amount of current from your usb port on average this is probably 250 milliamps full brightness is easily gonna pull half an amp just a tip here when driving your leds the rgb values here max out at 255 try to just do half of that like 120. these leds are numbered starting from zero which is the mode key and match the key numbers key one is also led1 in the code there's a footprint for a capacitor on each led this is recommended by the led manufacturer per their potato data sheet i haven't seen the need for it yet these leds have survived a 24-hour burning test so maybe these pads would be removed in the future i'm not sure but your mileage may vary the last step to connect our leds is the resistor for the data inline this resistor should be between 200 to 500 ohms and it just protects the current going into the data inline i'm using a 330 ohm resistor here the reset button used for programming can be soldered in now an optional stereo headphone jack or trs jack can be soldered from the top or bottom side too i recommend top for now as a reminder there are diode bypass jumpers here too don't forget to populate a diode here or just solder the bypass the headphone jack copies keys number two and three the keys between the encoders and can be broken out to an external switch like a foot pedal or giant button under your desk the pin out for the trs jack looks like this if you want to connect a potentiometer or volume knob you can solder it directly to the location here you could also solder a screw terminal with a five millimeter pitch this would allow you to connect a larger external potentiometer setup if you want it this board fits either the arduino pro micro with a micro usb or a mini usb connector the boards are functionally identical except for their overall width and the obvious inferior micro usb connector if you have commitment issues like me you can use female headers as a precaution so the microcontroller board is removable sockets or milled headers can be used if you want a lower profile when mounting the pro micro you can also solder it directly directly soldering the pro micro will give you the cleanest look when we slap a custom 3d print case around this keypad you could solder it from the backside too if you're attempting to make a custom enclosure and want to eliminate bulk just pay mine to the orientation if soldering the arduino from the underside the 32u4 chip should be pointing the same direction as the keycaps and that's up the last step is soldering the encoders and the cherry keys just a note by 12 millimeter tack switches can fit in place of the cherry keys if you need a usb hid input device on the cheap the 3d printed case serves double duty as a jig to keep the cherry keys aligned and square when soldering [Music] some encoders have two fins or tabs that supply extra mounting strength however these holes had to be removed from the footprint to fit these specialty leds you can bend or snip these tabs off if they get in the way just a side note the encoder footprint is compatible with five pin encoders meaning two pins are reserved for a switch so you don't lose a function of a cherry switch here if you use the encoder that has a built-in switch to assist with light diffusion when an encoder is populated instead of a cherry key you could drill a hole through a clear key cap i'm not totally convinced this is a good idea but it's an idea to get the most out of the leds you should be using cherry rgb keys these have a translucent body to help diffuse light clear keycaps are also recommended keycaps with a window will also work and as we all know going all black will net you the most style points the 3d printed enclosure will also help prevent light bleed between the leds and your keys you can use non-rgb keys solid color keycaps and skip the leds altogether if you're going for a build with less flare versatility is the key here final assembly is the 3d printed case this is still a work in progress for me right now it's two halves with a beveled lip to align each half i'm not really sure if the screw holes fit the look but they are there to help align when soldering the keys the two main differences are the cutout for the pro micro i might change this case to a single part but designing it takes time especially the printing portion of testing i'll post the stl files and a dxf of the pcb layout if you want to cad your own you should be able to print this stl at 100 scale no need to make it larger this case was drawn to accommodate for pla and abs shrinkage i have not tested any other filaments i don't have an elegant solution to integrate the lcd i think the real intent is a tiny oled screen which i don't have right now so these angled feet work fine in my case as far as programming is concerned details are on my website here are some key points make sure you have the correct libraries installed to follow along with the rest of this video you need these libraries and these are the versions i'm using keyboard.h keypad.h mouse.h encoder.h liquidcrystali2c.h and adafruitneopixel.h and finally when programming the arduino the bootloader portion that will accept and upload is a short window and i mean this by timing it might take a few tries to get the timing down in my case when the ide resets my pro micro it takes too long to compile and therefore misses the window of time to upload the pro micro by default will switch over to the usb hid mode and the ide throws me a programming error like it's unable to talk to it to resolve this i just hold down the reset button until the ide says it's trying to upload you might have to enable verbose output in order to see this text when programming the arduino it might take a few tries but you'll get the hang of it okay if you're still with me i'm going to take the rest of this video to talk about some fun keyboard macros i've broken this idea into a few main arduino sketches those are going to be simple expert and maybe whatever's left over which probably is another video here's some of the macro ideas i'll be covering remember links to the code are in the youtube description speaking of support documents there is again a new planogram template you can print out if you're brainstorming macros and trying to remember the layout or what key number is set to what color you can use this printout to aid that process as a final reminder many of these macro examples navigate windows which is a gui or graphic user interface you have to buffer most commands with pauses or delays to allow your system to catch up with these android like speed input commands if these macros or your own aren't working quite right it's likely because your operating system can't keep up with the input speed or it's still loading some gui element before it will recognize the next input command make sure you add delays so your system ui can catch up the last gotcha is macros that use function keys like control alt or the command key or windows or mac key i don't whatever make sure you call to release these keys if you have regular key commands following after triggering a hotkey this end zoom call macro is a good example the option to end a call is alt plus q but to select the end call option you also have to press tab then return to confirm it before doing the tab or return you must release the alt key and this is usually a big stumbling point when making your own macros okay let's move on the first improvement i added after my original macro keyboard video was adding different profiles for the rotary encoders the whole point of this macro keyboard was the mode button you can program a multitude of profiles for the key sets but i didn't write that example code to have unique encoder functions across all the profiles so let's change that recall the left encoder is encoder a and the right encoder is encoder b now we'll make a separate loop for each new function encoder a has a custom function for every profile that's encoder a underscore mode 0 1 2 and 3 and the same thing applies to encoder underscore b these are defined outside the main program loop so you can have as many of these subroutines as you need for encoder profiles when switching between the case statements aka the key profiles we can just call the encoder mode within that loop and then we're done we've got a custom encoder for each key profile this customization pays off most in video editors i use this keyboard primarily for video editing now like the video you are watching now scanning and scrubbing across the timeline is best with a rotary knob being able to switch between zoom levels coupled with snapping across splices makes the workflow so much smoother okay so what other things can you do with a custom encoder profiles i'm so glad you asked i added the mouse.h library to this example code with this we can mimic usb mouse inputs we can control not only the cursor but the mouse clicks and the scroll wheel so what's the most useful implementation well let's make a digital etch-a-sketch in microsoft paint i made a macro to open paint with one button that works by holding down the windows key and the letter r typing in ms paint followed by the return key this key sequence launches ms paint the left encoder moves the mouse cursor left and right the right encoder moves the mouse cursor up and down this is done by the mouse dot move command where the first digit is left the second digit is up and down and the last digit is the scroll wheel the value here is the number of pixels the cursor will move this range is negative 128 pixels to a positive 127 pixels the sine of the integer is how we determine the direction in whatever axis you've picked the way the paint program works is you have to hold down the left mouse button to draw we can map this to the encoder movement by calling the mouse.press mouse underscore left before moving the mouse so this is holding down the button then releasing after we move our set amount of pixels this is fundamentally like clicking and dragging but it's locked to the x or y axis you can see this effect if i move the mouse cursor over the frame of an application it's the same as clicking and dragging if you're using these encoders it clicks and holds and moves a set amount of pixels depending on your screen resolution you might want to adjust the mouse.move values so please enjoy whatever i'm drawing here and oh yeah this doesn't work unless you've selected the pencil or freehand tool in ms paint now that we've opened the possibility of mouse control let's make a custom arcade controller some really expensive arcade controllers are spinners sometimes called paddles or just freewheeling encoders most trackballs also fall into this category so let's see if we can make one we can mimic a basic encoder for brick breaker games like arkanoid or single axis movement games like tempest this is really only for mouse compatible main games just by the way if analog mouse movement isn't natively supported by the game and emulator this isn't going to work as described because we're using the mouse hid input library clockwise or anti-clockwise rotation of the encoder will move the mouse left or right but the tricky part here is the sensitivity well i found another idea for that analog breakout that i put on this pcb i placed a variable for the mouse movement and that gets read from the analog potentiometer i map the analog values from 0 to 1023 to 1 to 124 and that fits the constraints of the mouse.move parameters if you don't do this this value will roll over and it's going to make your mouse behavior very erratic adjusting the potentiometer will change the sensitivity for the mouse that move or the amount of pixels that it actually is going to move this is really helpful to get the feel of the rotary encoder when playing a different game i know a few people are commenting now this really isn't a spinner as a traditional arcade would have it but you can definitely achieve that same thing with a flywheel setup that would overcome the friction of the encoder's pits and valleys if you expand on that you might have to build out the hardware to be a little bit more robust for that situation and this is i guess an example of what you could start to do so this encoder or spinner would also cross over for a lot of racing games that use analog input in maim there's a lot to explore here and i've only touched the surface and just to expand upon the common questions yes this works with tempest and it also works for centipede but that's kind of a that's more of a trackball kind of game so this input is a little stiff here's an example of what not to do when managing secure access to sensitive account data maybe you're tired of browser extensions managing your passwords or you want the next step above storing your passwords under your keyboard you can try this program with all your logins and passwords in this macro keyboard we'll use a keyboard.print to type in the login string then send a tab key that's nine in decimal for the keyboard library then a keyboard.println to type in your password plus the return key to log yourself in this is a simple one key solution to log in through all your accounts again i'm no cyber security expert there are some obvious flaws here but let me humor you with this idea speaking of poor security are you tired of having to think of passwords all the time let's create a password generator that runs inside this macro keyboard anytime you need a hack proof password just press a button to generate some random alphanumeric nonsense to do this we need four random numbers and four character arrays to randomly pick lowercase letters uppercase letters numbers and special characters every time you press the password generator key you get a series of four random characters in this order so how does this work the random number gets assigned as the array index which selects whatever character is located at that position within the array by the way the random number generators are capped by the array size so we always picked a character in the array even if you edit the array the size of command will always create an index upper limit that matches the array size okay so we picked a random character in the array and remember this is done for every character ray lowercase uppercase numbers and special characters each character is converted to a string so we can combine all these selections together and then finally converted back to characters and printed using the keyboard print now any machine learning password crafter would surely test for patterns the generator's biggest flaw is it's always going to create a password with a series of four repeated lowercase uppercase digits and special characters in this pattern but pay no mind to this flaw because this password security checker says 20 characters of this type of password is basically uncrackable so let's call that a win you could expand this code to always mix the types of characters but we have more macros to talk about so let's move on because why not a slightly more useful but still fun example centers around opening your browser and launching this url every time you press this key it's going to open a random wikipedia article for your browsing pleasure you could even do something more useful like make a favorites remote for those who are less computer proficient and only use a few computer applications if this was for my dad every button would just launch solitaire from windows xp i just want to take this time to say this was not an easy feature to implement i started this idea with the standard 5x5 millimeter addressable leds that are on strips and tried to retrofit them in the older macro keyboard it didn't work but hinted it could be done i spent the next two months buying leds that were small enough to fit under a cherry switch but big enough for most people to solder after some searching i landed on this sk6812 mini e which was the right size but required milling a square hole for every led but before i talk about this struggle let's remember what happened previously why buy it when you can build it for three times the cost if you forget to label the other half of your nets like here a smaller six by six millimeter button so another revision later anyway i didn't use a resistor array until now i'm just not sure realize the mini usb pro micro four has a fatter layout [Music] okay now that we're caught up let's talk about milling that square hole using the eagle cad to do this was a chore i'll skip the usual mistakes i make like forgetting to label my nets on a board which i still managed to do but using eagle in general is an exercise in why and making a package from scratch with million instructions was not simple you might notice that a four millimeter diameter drill would still get the job done and would avoid milling altogether i tried to swallow that pill but it brought me great shame this sidestep of defeat is not something you want to show the internet so after a bit of back and forth and some wishful thinking and a few ash park tutorials later i drew what is apparently the correct milling callouts for routing a non-plated slot this was more guesswork than anything i had to wait for my board samples to come back to evaluate if i was on the right track or not the 2 engineering review of my gerbers was not enough to trust what i thought was correct i had to wait for samples to get to me before fixing any hunches on the next revision at the time of this video i'm still waiting on an updated revision because with all my focus on the mill slot i managed to goof up the silk screen layer twice i forgot it completely on one version while making a bunch of errors in the next with overlapping callouts i did change pcb fabricators for this board so i'm learning this fabrication house's gerber preferences all over again anyway let's talk about how to drive these leds just use the adafruit neopixel library and it's pretty simple here are some examples of how you can animate a color fill or the simplest but most effective way to assign specific colors to each key is this here's a color gradient that's very retro wave it's just mixing two colors gradually this code also implements flags to change the backlight coloring only when necessary this keeps the microcontroller resources free as the rgb backlight is only updated when the mode button is pressed meaning when you're cycling between key profiles this also leans into a nice feature of 6812 leds as they hold their color instructions once set the loop that is checking for a key press is free from having to update colors all the time here's another example that gives a visual cue when you press a button in this example after a key is pressed we change the key color there is a bounce delay that also holds this color long enough for us to notice it to return the key back to the idle color the color update flag is set to zero when the loop cycles the colors will be reset and the color flag will be now set to one this means the color change routine will be ignored until an event triggers it again this saves instruction resources so the pro micro is more responsive to the macro key presses again we don't want to waste processing cycles updating led colors we want to be waiting for key presses and macro instructions hence the need for setting flags like this remember that i scored c breakout connector the one with the selectable voltage solder jumpers you only soldered one jumper right okay good let's connect an lcd i only have the 4x20 modules which require 5 volts so i have the v-raw jumper soldered which supplies the usb rail voltage from my pc or whatever usb port i plug this keyboard into i only want to mention how the code updates the lcd like the leds a flag is set to indicate if the lcd should be updated that's the lcd update number routine you can have one for every mode or a custom key profile these case statements are just the screen updates or refreshes since we have 12 keys this screen has four lines so to cycle what each key does we're just going to refresh the screen three times and this is going to loop indefinitely while we're in this key profile mode to save from tying up the pro micro from unnecessary screen updates we're going to set a time stamp every three seconds and you can change this to longer or shorter so if the timer marks three seconds have elapsed we cycle to screen one after three seconds then we update to screen two and finally after another three seconds we refresh to show screen three the flag is set to go to screen one and then this cycle repeats this method again saves from unnecessarily updating the lcd which keeps the program more responsive for keyboard inputs the lcd screen doesn't instantly update when changing modes but it calmly cycles between screen you can expand the number of refreshes or pages by adding cases to this subroutine just make sure the last case sets the flag to zero so it will loop back around to the first page [Music] okay wow that was a lot of stuff okay it's time to wrap up this video and this project remember links to all the code or most of the code and 3d print files are in the description you can also find the schematic if this is something you want to pursue as a modified design on your own if you want to purchase this pcb and build your own professional grade macro keyboard just follow the links i've still got some outstanding why did i do this design quirks that i want to resolve but i don't really know if i'll ever fix that like what's this hole for why is it useful the answer is i don't know i just put it there because i like mounting holes in sets of four i've also got some more macro ideas that were to focus for this video and just make this video way too long i'll post another video for more arcade related implementations with a macro keyboard happy making and thanks for watching you
Info
Channel: RetroBuiltGames
Views: 334,741
Rating: undefined out of 5
Keywords:
Id: IDlcxLQ1SbY
Channel Id: undefined
Length: 32min 22sec (1942 seconds)
Published: Fri Dec 25 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.