Music Control In Your Car Using Puck.js

About the project

In this video I show you how to set up Puck.js to control your mobile phone's music playback by pressing it in different ways.

Project info

Difficulty: Easy

Platforms: Espruino

Estimated time: 2 hours

License: Apache License 2.0 (Apache-2.0)

Items used in this project

Hardware components

Puck.js Puck.js http://www.espruino.com/Puck.js x 1

Software apps and online services

Epruino IDE Epruino IDE

Story

It uses Puck.js's Bluetooth LE HID capability.

You could extend this relatively easily - for instance:

  • Detection of more types of clicks (eg. > 1 second)
  • Soldering more buttons directly to Puck.js
  • Soldering wires for external buttons (perhaps unused buttons that are in your car's dashboard)


Software

The code used in the video is:


  1. var controls = require("ble_hid_controls");
  2. NRF.setServices(undefined, { hid : controls.report });
  3.  
  4. setWatch(function(e) {
  5. var len = e.time - e.lastTime;
  6. if (len > 0.3) {
  7. controls.next();
  8. digitalPulse(LED1,1,100);
  9. } else {
  10. controls.playpause();
  11. digitalPulse(LED2,1,100);
  12. }
  13. }, BTN, { edge:"falling",repeat:true,debounce:50});

Credits

Photo of Espruino

Espruino

Espruino, Espruino Pico and Puck.js are low-power Microcontrollers that run JavaScript. Espruino is a JavaScript Interpreter for Microcontrollers that is designed to make development quick and easy. The Espruino interpreter is firmware that runs on a variety of different microcontrollers, but we also make Espruino Boards that come with the interpreter pre-installed and are the easiest devices to get started with. However Espruino itself isn't just the interpreter firmware or hardware - there's also the Web IDE, command-line tools, documentation, tutorials, and modules that form a complete solution for embedded software development.

   

Leave your feedback...