refactored LED code to be shared by node.js and browser