Arduino element

Together with the Firmata 2 firmware (an Arduino sketch uploaded to the Arduino board), this element allows you to control an Arduino board from your EJS simulation. You will be able to:

The Arduino board an be connected either by:

Usage

To add the element, simply drag and drop the element from the palette, to the list of elements for your simulation. If the board is connected to the ethernet, edit the "Server IP:" and "Port number:" fields accordingly. (The board must be loaded with the StandardFirmataEthernet sketch of the Firmata 2 firmware with the corresponding IP address and port.)

Connection methods

Information methods

Configuration methods

Output methods

Input methods

Example of use

if (!arduino.connect("/dev/tty.usbmodem1421",57600)) { // "/dev/tty.usbmodem1421" a USB port on a MAc computer. Try "COM3" on a Windows machine
  _view.alert("","Error","Arduino board not found:\n  "+arduino);
  _pause();
}
else {
  _println("Arduino connected: "+arduino);
  arduino.writeDigital(8, true); // Sets the digital pin number 8 to ON 
}