BeagleBone Black and Pulse Width Modulation (PWM),
Controlling a Servo Using HTML5, JavaScript, and Node.js.
Part 1 of 5

written by Babak Parvizi

A couple of years ago I attended Google I/O where they unveiled the Accessory Development Kit (ADK), which enabled Android developers to start interacting with hardware devices such as the Arudiuno. It had been a while since I felt excited about something, and this really got my attention. Having been primarily a front-end software developer, I had never heard of the Arduino or microcontrollers before, but Christmas was about to come early. The generous people at Google gave us all Arduino ADK boards, and I couldn’t wait to get home and start learning this new world that I had never experienced before.

I started with the “Hello World” equivalent for electronics by making an LED blink.  I learned how to turn a servo, made noise using a piezo, and so on.  It was then time to visit Radio Shack and start experimenting with more advanced sensors like a rangefinder and infrared sensors. Arduino made these experiments easy as the sketches were readily available, and it was just a matter of plug and play.

Ultimately, my goal was to be device and platform agnostic.  I didn’t want to be constrained to just Android devices, and I desperately wanted to expand my efforts to the iPhone or any other device of my choosing.  Unfortunately, Apple turned down my application for the MFi licensing program, and my hopes to connect the Arduino to my iPhone via the 30 pin dock connector or Bluetooth quickly evaporated.  I turned my efforts to using the ethernet and the wifi shields, but found communication via HTTP to be too limiting and underperforming.  Feeling restricted, I quickly grew disenchanted and lost interest.

A lot has happened in the last couple of years, however, that has re-sparked my interest and enthusiasm.  Small, faster, affordable microcomputers running embedded Linux have emerged like the BeagleBone Black (BBB).  Server-side Javascript using Node.js has taken web technologies by storm, enabling devices like the BBB to seamlessly run a web server out of the box in a non-blocking I/O fashion.  Open Web Standards continue to push the capabilities of HTML 5 devices, allowing mobile phones and tablets to communicate with external accessories like the BBB without the need for proprietary technologies or licenses.   

In this series of posts we are going to configure the BeagleBone Black (BBB) for Pulse Width Modulation (PWM) in order to operate a micro servo. We’ll then control the servo using an HTML5/JavaScript web client that will communicate with a Node.js WebSocket server running on the BBB. Here it is in action:

Update to the Latest Angstrom Distribution

First, make sure your BBB has the latest Angstrom distribution installed. You can find the distribution information using the following command once you ssh into the board:

The latest distribution at the time of this post was Cloud9 GNOME Image 2013.06.20. Here are some really excellent tutorials on updating to the latest image:

In the next post we will configure our BBB for PWM!

Next- BeagleBone Black and Pulse Width Modulation (PWM), Controlling a Servo Using HTML5, JavaScript, and Node.js. Part 2 of 5


2 thoughts on “BeagleBone Black and Pulse Width Modulation (PWM),
Controlling a Servo Using HTML5, JavaScript, and Node.js.
Part 1 of 5

  1. Pingback: BeagleBone Black and PWM, Controlling a Servo Using HTML5, JavaScript and Node.js #beagleboneblack @TXInstruments @beagleboardorg « adafruit industries blog

  2. Pingback: BeagleBone Black ใช้ Pulse Width Modulation (PWM) ควบคุม Servo สั่งผ่าน Node.js และหน้าเว็บ HTML5+JavaScript | BeagleBone Lover in Thailand

Leave a Reply

Your email address will not be published. Required fields are marked *