Sunday, 10 August 2014

Programming Arduino with JS

As we mentioned earlier, we are using Javascript as the main programming language through out the project. The Arduino microcontroller can be controlled through the use of frameworks like Rick Waldron's Johnny-five for Node JS, and the "StandardFirmata"software package for Arduino. 

Yeah we will be most likely utilising the Node.JS framework, which includes packages that allow for ease of communication between hardware and software. This enables us to handshake between Arduino Firmware and the Firmata protocol. Structure of the whole system is shown below.




The use of Johnny-Five library immensely helps us make the code more efficient compared to the normal Arduino C. For an example, assume we want to control a DC motor for 1 second. In Arduino C we use delay (1000) function in order to switch DC motor on for one second. Delay function blocks the execution process for entire second. If this program is reading other sensors, those sensors are also blocked for one second. However using Node JS and Jonny-five the tasks are scheduled and they will be called in a later execution turn allowing other sensors to read/write as normal.

Derick Bailey has done an AWESOME tutorial on how to use Arduino with Johnny five library. 


No comments:

Post a Comment