USB media controller for windows and Android devices

On the development of this crafts I was prompted by the article USB volume control for the PC and not only.
But just “volume + mute” didn't suit me,I would like to have functional buttons to control the player. Since I didn’t have anything to do with the AVR at all, I decided to order one thing Digispark85 (with a microUSB port). While the package was traveling, he smoked manuals, rummaged in the corner of a necromancer and tried to figure out the design of the case.

The review will not be unpacking, TTX, descriptions Attiny85 - immediately to the point.
Introduction The controller uses a constantconnect to host device via USB, using two ports (P3 / ADC3, P4 / ADC2). Two more ports are used for the encoder (about them below), one is used when (re-) programming the controller (P5 / ADC0 / Reset). Thus, for the block of function buttons one port remains. The easiest way to connect it is according to the classical scheme with a resistive voltage divider, and to recognize the presses, use the built-in ADC controller. Based on the restrictions (see above), the only option left for such a connection is to the P2 / ADC1 port.
The encoder will be connected to ports P0 and P1 (instead of P0 and P2 as in a USB volume control for a PC and not just a variant), but the built-in “mute” button in the encoder will be placed on a block of buttons (sorry for tautology).
Schematic diagram of the controller. Pay attention: the LED connected to port PB1 is excluded from the scheme.

A bit of mathematicsNumber of additionalbuttons depends on your imagination, but is limited by the amount of software code, the accuracy of the ADC and the selected bit depth. For my needs, 5 buttons and an 8-bit ADC mode are sufficient. As a reference voltage, it is best to use Vcc (when powered from USB, this is approximately + 5V + -dopusk), while the results of ADC readings will not depend on fluctuations of this voltage. For a clear recognition of the presses, I selected the resistor ratings so that the difference between the ADC counts for the adjacent buttons was at least 40.
To simplify the calculations made the table (attached)by which you can choose the optimal parameters of the divider and calculate the thresholds for determining the pressed button. The three right-hand columns with a gray header contain actual measurements and calculations for the ADC after the assembly of the block, they are used in the program code.

The conversion rate of the ADC depends on the currentthe clock frequency of the microcontroller and the selected divider, the so-called. prescaler’a. The device operates at 16.5 MHz, therefore, for the ADC to function, it will be necessary to set the maximum value to prescaler = 128. This will provide clocking with a frequency of approximately 128 kHz, the time for one conversion will be 1/10000 s.
The software part Represents the modified code from TrinketVolumeKnobPlus, from which the excess has been removed and the necessary one has been added.
When you press and hold any button,only one command (keystroke repeat lock), but if you like, you can modify the code so that when you press <> the controller repeats the corresponding commands.
After compilation, the firmware takes about 60% of the allocated 8KB flash memory (part is occupied by a special bootloader).
Listing under the spoiler

Printed circuit board and package The printed circuit board is Digispark itself. Connecting to external devices - through a regular microUSB port.
For the block of buttons, I used a control stripfrom the old burned-out monitor LG, changing in accordance with the table SMD resistors. The scarf and the supporting frame with the pushers were slightly shortened, the sides glued up the socket for the cable for rigidity. Connection with Digispark85 - soldering.

But the body still exists in the preliminary drawing and oak logs