2 button keyboard
I wanted a simple keyboard with play and pause media keys to make it convenient to control my music.
To handle the USB, I used a STM32F103 based "blue pill" board because they're cheap and easy to work with. First I put together a simple design in easyEDA.
For the layout, I had some plastic cases I wanted to use. I was originally thinking I would have to mount it to the plastic lid, so I put drill holes in the PCB for the screws.
I sent the PCB design off to be made and ordered some parts.
I made sure I had a working program and bootloader before I did anything else. I used the stm32duino bootloader and libraries to put together a simple sketch:
The USBComposite library already had a consumer HID USB device defined. I used a composite device so it'd have serial for debugging and to access the bootloader. I had to put the PLAY/PAUSE key definitions into the USBHID.h file.
The programming header and the boot jumpers on the blue pill won't fit in the case, so I had to take them off. I soldered all the pieces together and tested it out.
I made some holes in the case to fit things through. I was originally thinking I'd drill the case, but I didn't have the right tools for it. So I used a knife instead.
I had originally planned to attach the board to the top of the case with M2.5 screws, but it turns out the board was exactly the right height and didn't need to be screwed down.