Basic Finite State Machine for Arduino
A very basic example for the Arduino platform that switches an LED on
This example was used in an article on the website instructables.com. You can read
the article here.
It demonstrates how to get started with YAKINDU Statechart Tools and the
Arduino platform and contains a timer service for the Arduino. You need to
have an Arduino plugin, as described in the example "Arduino traffic
light" and in the linked article.
Addons for compiling and flashing
All Arduino examples can be compiled via command line or be imported into the Arduino IDE. An easier way is using the Sloeber plugin , which allows you to compile and upload the code directly in Statechart Tools.
How to install the Sloeber plugin
There are two ways of how to install the plugin. The easiest way is using our example wizard, which allows you installing required plugins. Just follow the built-in instructions.
Another way is installing the plugin manually. You need to follow these steps:
- Click on 'Help' -> 'Install New Software..' -> 'Add...'.
- Define a name and add 'http://eclipse.baeyens.it/update/V4/stable' as location.
- Choose the plugin - not the IDE.
- Follow the instructions
- The installation dialog will ask you for a restart. After this restart is done, the installition it will download some files. Just wait until it's finished
Configure the Sloeber plugin
After the installation you should notice a new Toolbar, which allows you to compile and flash your Arduino.
Initially, the projects are not configured, as you may require to add the toolchain:
- Click on Window -> Preferences
- Open the Arduino window -> Platforms and Boards
- Depending on your Arduino, choose the board. For the UNO click on arduino -> Arduino AVR -> check out one toolchain
- Click on Apply and Close and wait until the downlaod has been finished
Some examples may need different libraries. E.g. the LiquidCrystal lib. If so, repeat the steps using the Library Manager and add your required lib.
Configure the example
Once you have installed the toolchain for your Arduino, you can configure the project.
- Right click the project and open the Preference page
- Open the Arduino window
- Choose your platform and port
There will be a dialog, which warns you that the platform.txt is missing. This is not a problem and will be resolved after the intitial configuration.
Compile and upload
Finally, you can use the green toolbar for compiling and flashing the Arduino. Have fun!