At home we ripped all our audio CDs to a NAS and most of the time we use Windows Media Player or VLC player (we still don’t agree which one’s the best) in random order play to have some background music in our workshop. But with a huge collection of artists and different music styles, sometimes a track is played ‘at the wrong time’, gets on your nerves, and you feel the urge to rush to the PC to skip it. Of course this is not always easy when you’re busy and most of the time the track already ends before you are able to reach ‘next’ button on the PC. A remote control would be an option, but these things have the habit of being untraceable when you need them, not to mention the issue finding the correct button once you found the RC.
We found a better solution in a robust industry-standard emergency stop button I once bought on a flea market for just 1 Euro (okay, these are really expensive when you buy a new one!), in combination with a small ATtiny85 board that translated a key press into USB HID Media Control code ‘next track’. But there was still a (long) cable between this button and the PC, waiting for time, mood and inspiration to make a more practical wireless version. The idea was triggered again when I worked on the wireless quiz button project in the Elektor Lab, with its nice and small battery powered nRF24L01 transmitter boards. Easy to handle with available Arduino libraries, the only thing missing was the bridge between an nRF24L01 receiver and USB (consumer) HID to instruct the media player software to skip to the next track. Around the same time I found Nico Hood’s Arduino Hoodloader project on the internet which seemed nice to experiment with, and so the wireless Skip Button was finally made. The first version was built with an Arduino Uno plus an ELPB-NG prototyping shield. Not the smallest and most elegant solution, but it was fun to build it with an Arduino Uno board that was only collecting dust.
The Arduino Uno needs no further introduction, since its release way back in 2005 there have been numerous successors based on the original concept. It does have a USB-connector, but this is only intended for programming, power supply and UART connection to a computer, not for real USB-based applications. Few people realise that there is a second microcontroller on the board, that mainly serves as a UART <-> USB bridge between the ATMEGA328 (and its bootloader) and Windows/Linux/Apple computer. This chip –an ATMEGA16U2 on most Arduino Uno boards- is also programmable via USB with special utility programs like Atmel’s Flip and even has its own on-board ISP connector for flashing its firmware. There were already other firmware versions for this chip available that added USB (mostly HID) functionality to the Uno, but the downside was that the user had to revert this firmware to the original serial-USB version in order be able to (re)program the 328 via the Arduino IDE.
Nico Hood developed the Hoodloader, a special bootloader for the 16U2 that contains a USB stack and that can also switch back to ‘normal Arduino mode’. Simply put: with the Hoodloader your original Arduino Uno turns into a board with two independent microcontrollers that can both be programmed from the same IDE. The ATmega328 serves as I/O-microcontroller (the ‘original Arduino), while the ATmega16U2 contains the USB functionality. Both can run their own sketches, with the only –possible- interaction via the two-line UART connection between the microcontrollers. Sounds great and easy, but I must admit that it took me some time to find out how to work with this enhanced Arduino Uno concept in the Arduino IDE. Furthermore, the microcontrollers both have a sketch running, and the user must implement some kind of protocol to let the two communicate. For my application I used the aforementioned UART connection between the 328 end the 16U2. The ATmega328 runs a sketch that listens to an nRF24L01 receiver and simply sends a byte over the on-board serial connection to the 16U2 when a valid signal from the wireless button is received. The 16U2 listens to its serial input and sends the corresponding ‘next track’ USB package to the computer/media player software. Please note that the ATmega16U2 (possibly) can handle this application on its own, it can interface directly with the nRF24L01 and doesn’t really need help from the ATmega328. The 16U2’s SPI pins are accessible on its ISP-header and some additional I/O pins are connected to solder pads next to this connector. But here I just used this idea to play with the Hoodloader, to see how to work with two sketches running on an Arduino. And of course: a small ATmega16u2-board that fits inside a standard USB-stick case is under construction now…
There is much more to tell and to know about the Hoodloader project than the simple application presented here, but this may help as a starter. Please refer to https://github.com/NicoHood/HoodLoader2 for more information.
For the transmitter -the real Skip Button- we used the design of the Wireless Quiz Button (see https://www.elektormagazine.com/labs/wireless-quiz-buttons-150499-i), we just took the red button from this project without any changes in hardware or software.
SKIP!! (single button Media Player control via USB)
19. Februar 2016 , Letztes Update: 21. April 2016
in Elektor | July 2016 | Zum Heft-Artikel...
- 150650-11 ELPB.zip (1.81 KB )
- BOM-150650-1_ELPB-NG Skip-v1.0.xlsx (17.03 KB )