You are on page 1of 7

Arduino plugin tutorial

Table of contents
Arduino plugin tutorial.........................................................................................................................1
Quick start............................................................................................................................................1
Upload BreakoutFirmata to your Arduino...........................................................................................1
Run the Breakout Server......................................................................................................................2
Install the plugin...................................................................................................................................2
Use the plugin......................................................................................................................................2
Settings............................................................................................................................................2
On board ready................................................................................................................................2
Enable pins......................................................................................................................................3
Input pins.........................................................................................................................................3
Output pins......................................................................................................................................3
/ Here are my enabled pins..............................................................................................................3
Input pin changed............................................................................................................................4
Control output pins..........................................................................................................................4
Mobile..................................................................................................................................................4
Exporting for HTML5..........................................................................................................................5
Mobile on a local server..................................................................................................................6
Compatible I/O boards.........................................................................................................................6
Tested Arduino Boards....................................................................................................................6
Compatible operation systems.............................................................................................................7
Compatible mobile web browsers........................................................................................................7
If you are stuck.....................................................................................................................................7

Quick start
To start quick please watch this video: https://youtu.be/8RK-fasJs9A

Upload BreakoutFirmata to your Arduino


We assume you are familiar with the Arduino application and the process of uploading new
programs (‘sketches’) to the I/O board. If you are new to Arduino, please first see the Getting
Started section for your platform (Mac, Windows or Linux) on the Arduino website. Or else, send
us an email and we can sell you an Arduino on which we have flashed the sketch.
1. Install the ConfigurableFirmata library: In the Arduino IDE, navigate to Sketch > Include
Library > Manage Libraries, then search for “ConfigurableFirmata” and click on Install after
tapping on the ConfigurableFirmata item in the filtered results.
2. Open our supplied sketch, "BreakoutFirmata.ino", in the Arduino IDE and upload it to your
Arduino board (make sure your particular Arduino board is selected under Tools -> Board and
that the correct COM port is selected under Tools -> Port).
BreakoutFirmata is a program that allows a client application running on a computer to
communicate with the Arduino, and is just one application of the Firmata protocol.
For more information please visit: http://breakoutjs.com/getting-started/ - or firmata.org for a
complete overview.
Run the Breakout Server
Start the Breakout Server on your compatible computer connected to your compatible Arduino (see
compatible devices at the end of this document) - and hit connect. This is essential every time you
run your Construct project.

The name of your computer and the network port you are connected to should be printed along with
the serial port your Arduino is connected to (on windows this will say something like “COM3”).
If you have a firewall enabled for your computer or network, make sure port 8887 is open, or
enter a new port number that is open (be sure to hit the enter key upon typing in a new port
number). For more information on the Breakout Server please visit
http://breakoutjs.com/getting-started/
Java Runtime Environment version 1.6 or higher must be installed. It’s pre installed on OS X.
Windows and Linux users may need to install Java. Get it at https://www.java.com/.

Install the plugin


In Construct 2: Drag and drop the Arduino.c2addon to your Construct 2 project. And restart.
In Construct 3: Select Menu > View > Addon manager. Then click “Install new addon” and find the
Arduino.c3addon file. Restart Construct 3.

Use the plugin


Settings
If you are running your game on the same computer connected to your Arduino, you can just leave
this be. If you are running the game on a mobile device, jump to Mobile5.

On board ready
To initialize the Arduino plugin, add the event "On board ready". This is essential!
Enable pins
Then enable the Arduino I/O pins you whish to use - as actions to the "On board ready" event.

Input pins
For analog input select "EnableAnalogPin". For digital input select "EnableDigitalPin".
Make sure the pin numbers you select are actually analog or digital input pins on your Arduino.

Output pins
For all output (digital output and PWM output/analog output) select "EnableDigitalPin".
Make sure the pin numbers you select are actually digital output or (for PWM/analog output) digital
output with PWM on your Arduino.

/ Here are my enabled pins

Input pin changed


Now in your Construct project, you can listen to changes in your input pins - digital or analog - like
this:

- And then utilize this event - for instance like this:

Or this:
Control output pins
You can also make game events that trigger outputs to the digital and analog pins:

-to for instance turn off an electromagnet:

Or to dimm the LED at pin 9:

Or to turn the servo at pin 6 via the compas in a mobile/tablet running your Construct project:

-here the "DeviceRotation" is a global variable that detects changes in the mobile/tablet compas
rotation and then - if the compas is also within 180 degrees (the normal servo limit) - sends a new
direction to the servo at pin 6.

Mobile
If you run your Construct project on a mobile/tablet, your Arduino still needs to be connected to a
computer running the Breakout server. And you will have to change the "Host" property in the
plugin settings to the computer's IP adress (you can look up your IP adress in Construct 2 /
Preferences / Preview / Preview on LAN address / ... /).

For more information on easy previewing and testing on your local network please visit:
https://www.scirra.com/tutorials/247/how-to-preview-on-a-local-network

Exporting for HTML5


We have had a request for demonstrating how you can export your Construct project for HTML5
with this plugin. A reason for this could be that the Construct preview server requires Construct to
run in the background - which requires a license, and then turns into a problem if you i.e. have
many physical installations of your projects. You can in this case just export for node webkit –
which will work too! But here goes for HTML5:

So, as allways with Construct, your project has to run on a server when exportet as HTML5. You
can host it on a remote server, and the Arduino plugin will work fine (if you access the webpage
from the same computer that runs the Breakout server. So you can't use a mobile/tablet this way).
You can also run a server locally. We recommend using XAMPP for that because it is free and easy
to use. Here is how:
• Download the installer from here: https://www.apachefriends.org/index.html
• In the "Select components" the only thing you really need is Apache. But we just take it all:

• Install it in the C-root (if you don't, you will have to change the httpd.conf file later on)

• Skip Bitnami for XAMPP.


• Now in the XAMPP controll panel start the Apache server:

• When started, you can browse the server at http://localhost/


• What you browse here all lies at C:/xampp/htdocs. So for the server to host your
HTML5project, just export it to C:/xampp/htdocs. Here I have exported my "arduinotest"
project from Construct:
• And to view it I point my browser at: http://localhost/arduinotest/

Mobile on a local server


To view the above page on mobile, I have to change the "Host" property in the plugin settings to my
computer's IP adress (see above mobile instructions) - and point the mobile browser to that. In this
case: http://192.168.2.8/arduinotest/

---------------------------------------------------------------------------

Compatible I/O boards


Tested Arduino Boards
•Arduino Due, Zero, 101
•Arduino Yun and Leonardo
•Arduino Uno
•Arduino Fio
•Arduino Mega 2560 (all pins are usable)
•Arduino Duemilanove
•Arduino Pro Mini
•Tested Arduino-compatible boards
•Teensy 2.0, Teensy++ 2.0
•Teensy 3.0/3.1/3.2, Teensy LC
The following boards should also work with the plugin, but have not yet been tested
•Arduino Pro
•Arduino Mini
•Arduino Nano
•Arduino LilyPad
•Arduino Diecimila
Compatible operation systems
•Mac OS X 10.6 or higher
•Windows 10, 7 or XP (you must have a 32-bit version of java installed)
•Ubuntu 11.10, 12.04 or 14.04 64-bit (32-bit may also work)
Java Runtime Environment version 1.6 or higher must be installed. It’s pre installed on OS X.
Windows and Linux users may need to install Java. Get it at https://www.java.com/.

Compatible mobile web browsers


•Safari
•Firefox version 7 or higher
•Chrome for Android

If you are stuck


Let's see if we can help you. Send us an email at fredslundmobile@gmail.com.

You might also like