Code ported to the Energia IDE (yet to be tested)