--{{0}}--
This document defines some basic macros for applying the JavaScript Arduino interpreter NetSwarm in LiaScript to make Arduino programs in Markdown executeable and editable.
Try it on LiaScript:
See the project on Github:
https://github.com/liaTemplates/netswarm-simulator
--{{1}}--
There are three ways to use this template. The easiest way is to use the
import
statement and the url of the raw text-file of the master branch or any
other branch or version. But you can also copy the required functionality
directly into the header of your Markdown document, see therefor the
last slide. And of course, you could also clone this project
and change it, as you wish.
{{1}}
-
Load the macros via
import: https://raw.githubusercontent.com/liaTemplates/netswarm-simulator/master/README.md
-
Copy the definitions into your Project
-
Clone this repository on GitHub
--{{0}}--
If you want to execute the loop only once, use @NetSwarm.single_loop
To use the Tau-Prolog interpreter, two macros are
necessary. The first one is @Tau.program
, which is called with a unique
identifier. It defines the basic Prolog-program with all rules and definitions.
void setup() {
Serial.println("Hello setup.");
}
void loop() {
Serial.println("Hello loop.");
}
@NetSwarm.single_loop
void setup() {
Serial.println("Hello stuff.");
}
void thing(char i) {
switch(i) {
case 0: Serial.println("a pear"); break;
case 1: Serial.println("an apple"); break;
case 2: Serial.println("an elephant"); break;
case 3: Serial.println("an arduino"); break;
}
}
void loop() {
Serial.print("here's ");
thing(random(4));
}
@NetSwarm.loop