Now, let’s write your first Ardestan program. Respecting the tradition of the hacker’s culture, we write a very simple program to display a message: “Hello, world!” inside the Serial Monitor pane of the Ardestan IDE.
Patch, Object, and Connections
A visual program in Ardestan is called ‘a patch.’ This is because Ardestan’s language design is originated from its predecessors, such as Max and PureData, both of which are quite popular in computer music and digital arts. In these languages, a visual program is called ‘a patch,’ possibly its visual program looks like a modular synthesizer patch of the good old time (see Figure 1 below).
Similarly as in a synthesis patch above, a program is created by connecting various software modules in a Ardestan patch. We simply call each software module ‘an object’ or ‘an Ardestan object’ in Ardestan. We also refer a virtual cable that connects an output of an object to an input of another object (or the object that produces output itself) as ‘a connection’ in Ardestan.
Creating a New Patch
First, select the menu item: New Patch from the File menu to create a new program.
Then, you will see a new window inside the Ardestan IDE, tabbed with a title (“untitled”), as shown in Figure 3.
Creating Ardestan Objects
To create our first Ardestan patch, we first place four Ardestan objects inside the patch window. To create an Ardestan object, just select the menu item: Object Box under the menu: Put.
Then, you should see an ‘object box’ in the patch window.
Alternatively, you can use the shortcut key (command + 1 for macOS or control + 1 for other platforms). An object box will be created below the position under the mouse cursor.
At this point, it is still just an ‘object box’ and it is still not an Ardestan object. Just click the object box and type “loadbang” to the object box, then it will be changed as a “loadbang” object as below.
An object box can be dragged to anywhere inside the patch window. Let’s create more Ardestan objects and place them as below.
Connecting Objects: Outlets and Inlets
You might have noticed that some Ardestan objects have one or more small rectangles at the top and at the bottom. These are called ‘inlets’ and ‘outlets’ respectively. An inlet is where an object receives an output value from another object and an outlet is where an object output a value.
In Ardestan, we connect inlets and outlets of various objects so that Ardestan objects can collaborate each other and perform the task you want to realize.
Let’s create a connection between the loadbang object and the string object we already placed in the patch window.
First click an inlet of the loadbang object (left above), and then drag the mouse (right above). Move the mouse at the left outlet of the string object (left below) so that you can connect the inlet and the outlet. After you successfully connect them, the connection will be created between the inlet and the outlet (right below). Now that the connection is created, whenever the loadbang object output a value from its outlet, it will be received by the string object at its left inlet.
Let’s create one more connection between the string object to the serial_println object as below (Figure 9).
Now, let’s save your patch by selecting the menu item: File > Save.
As we haven’t given any file name, a dialog window will be shown as Figure 11. We name this file as ‘hello.ard’ and save it inside the project folder.
If you successfully saved your file, it should show up in the Project Explorer window in the Ardestan IDE (Figure 12).
Building and Uploading Your First Patch
Now we have finished ‘coding’ of your first patch in Ardestan! Then. Let’s ‘compile’ your patch and then upload your program to Arduino.
First thing you need to do it to make it sure that your Arduino is connected to your computer. Then, select the menu item: Tools > Select Connected Board.
If you select this menu item, Ardestan will look for Arduino devices connected to your computer and show the dialog: “Select the Arduino device” as shown in Figure 14. your Arduino should show up in the connected box. Select one you want to upload your program and then press the OK button.
If you successfully selected the Arduino, the names of the Arduino and the connected port should show up in the window title of the Ardestan IDE as below (Figure 15).
Now you are ready to compile and upload your program to the Arduino! Yet, how can we do it? Select the menu item: Project > Build and Upload (Figure 16). Then, the Ardestan IDE will start compiling your program and uploading it to the Arduino.
If you have successfully compiled and uploaded your patch, you should have seen the messages as in Figure 17 in the Console window in the Ardestan IDE.
At this point, you may haven’t seen anything even though you successfully compiled and uploaded your patch to the Arduino.
Let’s move to the next section: Serial Monitor to see what your first Ardestan patch is doing!.