Introduction

Welcome to the second article on our series on XOD, a graphical programming IDE that allows you to rapidly develop software for the Arduino without writing any code.

Today we’ll expand upon our XOD skills and learn how to deal with projects that require nodes that don’t exist. I’ll show you how you can add XOD libraries to your IDE and also how to create your own custom nodes.

In order to illustrate an example of a “real life design case” I’ve decided to start building a XPOD-powered robot car.  As the series progresses I’ll add components to our robot and show you how to program your Arduino to handle these components, all with XOD of course.

Before we get started let’s do a quick recap of what XOD is and how to use it.

XOD Recap

In my article Arduino Visual Programming – Getting Started with XOD I discussed what XOD is, how to pronounce it (it is pronounced “zod”) and how to install the desktop client on your computer.

XOD Robot Part 1

We then moved on to discuss the basic elements of XOD:

  • Patches – A XOD program consists of one or more patches. This is the working area where you will assemble your XOD program.
  • Nodes – A node is the fundamental element of XPOD. A node can represent a logic function or an electronic component.
  • Pins – All nodes have one or more pins and these can be either inputs or outputs. Inputs pins are on the top of a node while output pins are on the bottom. The pins are where you enter values for the node and are also used to connect nodes together by linking the output pin on one node to the input pin on another one.
  • Links – Links are line that link the output pin of one node to an input pin on another node.

Essentially programming using the XOD IDE is performed as follows:

  1. Determine what you want to accomplish (true in ANY programming task!).
  2. Connect the target Arduino board to your computer via USB.
  3. Open the XOD IDE client and start a new project.
  4. Drag the nodes you need to accomplish your goal onto the projects patch(es).
  5. Enter constant data into nodes where required.
  6. Connect the nodes by creating links between specific inputs and outputs.
  7. Save the project.
  8. Deploy the project to the Arduino.
  9. Observe the results and repeat as required until your goal is achieved.

While XOD won’t completely replace the standard Arduino IDE it is still an excellent tool for rapid prototyping and for users who are more hardware savvy than code savvy.

You can learn more about XOD on the official XOD website.

The XOD Robot Project

As we continue to learn more about XOD I thought it would be a good idea to have a project to work on. This way instead of just going through the paces of using nodes, patches and libraries we will actually have a goal that we want to achieve using XOD.

In the original article we built a small project, a temperature and humidity gauge that used an LCD display and had a push button to change from Celcius to Farenheit.  And it did a good job of illustrating just how complex a device you could construct with a simple XOD program.

For our next project I’ve decided on a robot car base.  These are always fun to work with and the results are something you can show off to anyone. A robot car base can always be expanded, and each time we add to our design we can learn new XOD techniques.

Robot That Grows

Today we’ll build the base and add a couple of components. Next time we will add more components, and we’ll repeat the process a few time more until we have a complete XOD powered robot.

We will start today with just the basics – an L298N H-Bridge motor controller and an RGB LED.  As time progresses we can add some of the following components:

  • A Servo Motor and an HC-SR04 Ultrasonic distance sensor. This will be used to allow our robot car to avoid collisions and to ”self-navigate”.
  • IR Sensors for line-following applications.
  • An audio device like a piezo buzzer or speaker.

And the list goes on. Actually as of this writing I have no idea how this will turn out so I’d welcome any other suggestions for additions to our XOD robot car.

Robot Parts

Our robot car is built around a very common robot car base that you can easily find on eBay or Amazon.  These kits are inexpensive and are excellent value for experimenters.

The basic kit consists of a couple of an acrylic base with a number of holes and cutouts, a pair of DC motors, a rear castor to support the base, a battery holder and all of the hardware required to put it all together.

The kits also come with a pair of speed encoder discs, we won’t be using them in our initial design but might later.  If you’re interested in finding out how these work please see the article Build a Robot Car with Speed Sensors where I show you how to use an IR source-sensor and Arduino Interrupts to read wheel speed and rotation.

You could, of course, fashion your own robot car chassis with a couple of DC motors and a homemade base.  Another option is to convert a toy vehicle.

Robot Kit Assembly

I assembled the robot car base in the standard fashion. In my base the motors were only held in using one acrylic bracket for each motor, that seemed a bit weak (other designs use two acrylic brackets) so I put a bit of epoxy on each motor to hold them in place.

I’ve decided to power the motors using the 6-volt battery pack supplied with the kit.  This breaks with tradition with me as usually I opt for a 5-cell 7.5 volt supply instead. This is because the L298N motor controller will drop 1.4 volts so with a 7.5 volt supply my motors will receive a healthy 6.1 volts (when the batteries are fresh).

The reason for electing to use the supplied 6-volt battery pack is that I intend to add a servo motor to the design and I don’t want to power the servo from the 5-volt power supply derived from the Arduino.  Servo motors consume a fair bit of current and can also induce electrical noise into the power supply which could cause errors in your Arduino output.

I was concerned that the lower supply voltage would not be sufficient for my DC motors, after the voltage drop they will only be receiving 4.6 volts.  But I hooked a motor up to my bench power supply and was able to drive it with as low as 3.5 volts, so it seems like the lower voltage supply will suffice.

For the Arduino power supply I used a USB power bank. This is a convenient method of supplying 5-volts to a project, these devices are rechargeable and can be recharged with any USB charger.

I used an Arduino Mega for this design but you could also use an Arduino Uno. I chose to use a Mega because of its extra I/O pins and memory, although the code and hookup in this article don’t require it.

I also created a little “power distribution” circuit board out of perfboard. It is just a convenient place to gather together all of the supply voltages (5 volts and 6 volts) and send them off to the L298N and (future) servo motor.  It also holds the RGB LED, I used a 10mm LED because I liked the way it looked but any conventional RGB LED will work just as well.

Robot Hookup

The hookup of the XOD robot car (as it currently stands) is illustrated below. The diagram shows an Arduino Uno but if you elect to use a Mega like I did the pinouts are exactly the same.

XOD robot car wiring

Most of the connections are easily made with standard hookup wires and there isn’t a lot of soldering involved.  You will need to solder the wires to the motors and you may also want to hook up a power switch for your 6-volt battery supply.

When you connect the L298N H-Bridge be sure to remove the onboard jumper to allow the controller to be powered by the 5-volt output from the Arduino. Our 6-volt motor supply wil be insufficient to drive the L298N modules internal 5-volt voltage regulator so we need to use an external supply.

Once you have it hooked up it’s time to get working with XOD!

XOD Coding

I received some great comments (thank you very much!) on the original XOD article and video and one common observation was that as a XOD program grows in complexity it becomes very “cluttered” or “busy”.  The temperature and humidity gauge we originally built was on the verge of becoming too “cluttered”.

Of course the same can be said of a long Arduino program written in C++, or for that matter a complex program written in any programming language.

In other languages we can resolve this issue and make our programs more readable and reuseable by writing functions and calling them from within our main program. In some programming languages we can also split our program into several files.

In XOD a good technique for avoiding this predicament is to use multiple patches.

Using Multiple Patches

Every XOD program has at least one patch, by default it’s called “main”.  In the XOD programs we’ve worked with so far it’s the only patch we’ve used and it contains all of our nodes and links.

But XOD is capable of working with multiple patches. And every patch can become a node to be used in the main patch or within another patch.

Using the technique of multiple patches allows you to write very sophisticated XOD programs while keeping the main patch relatively clutter-free.

Another reason for using multiple patches is when you need to create a custom node for a piece of hardware that isn’t currently in the “common hardware” library in your XOD IDE.  

To create a new patch in your XOD IDE just go to the File menu at the top of the page and choose New Patch. You can also use the keyboard shortcut Ctrl+N on Windows or Linux or Command+N on the Mac.

RGB LED

Our RGB LED is an example of a component that does not appear in the XOD IDE common hardware library.   While we could certainly just use three standard LEDs and that would work fine but it would be more convenient to have an RGB LED node.

So let’s make one!

We’ll begin by creating a new patch to work on our custom RGB LED node. Open a new patch and name it “rgb-led” (it is conventional to name patches and noided in lowercase).

Next add three LEDs. You’ll find the “led” node in the “xod/common-hardware” library.  

BTW, a quick way of finding the LED (and any other node) is to just double-click on a blank area of the patch, this will open up a search box that allows you to search for any XOD node.  You can also choose Insert Node from the Edit menu to get the same search box.  Type “led” into the search box and click on the hresult to add an LED node to the new XOD patch.

Once you have one LED node you can highlight it and press Ctrl+C (Command+C on Mac) to copy it and then Ctrl+V (Command+V on Mac) twice to paste two additional copies onto the patch.

Each of these LED nodes represents one of the three colors in our RGB LED.

Label each of the LED nodes so you know which one is which, a simple “Red, Green, Blue” label should suffice.

An LED node has two inputs and no outputs:

  • PORT – A number input, this is the pin number of the digital I/O port on the Arduino board.
  • LUM – Also a number input, this is the luminance or brightness of the LED. It can be a value from 0 (off) to 1 (full intensity).

So our RGB LED custom node will need a total of six inputs, two for each LED node. In order to be able to use our patch within another patch as a custom node we will need to give it those six inputs.

Look in the Project Browser (on the left side of your XOD IDE) and navigate down to the xod/patch-nodes library.  Here you will find a number of input and output nodes made for exactly this type of application.

Since both of our LED inputs are of type “number” we will need to get six “input-number” nodes from this library and add them to our rgb-led patch.

Once you have done this add a link from each of the input-number nodes to the pins on the LED nodes.  You’ll then want to label each of those input-number nodes to correspond with the pin you’ve hooked it up to.

XOD rgb-led patch

Save your project and return to the main patch.

Now look in your Project Browser under My Project. You’ll see the main patch as well as the rgb-led patch you just created.

Drag the rgb-led patch onto your main patch. You will see that it now resembles a node!  And best of all, it can be used just like any other node.

Go into the rgb-led “node” and enter in the values for the three PORT pins as follows:

  • R-PORT (Red PORT) – 9
  • G-PORT (Green PORT) – 10
  • B-PORT (Blue PORT) – 11

Now adjust one or more of the LUM values so that the LED will be illuminated.  Save your work and deploy it to the Arduino.

Once the program is deployed to the Arduino you should see the RGB LED illuminate in the color(s) you specified.  You’ve successfully created a custom node!

It would be a good idea to go back and add a description to each on the input pins you used to build your custom node. Do that and save your project and then look at the new node in the main window. You should see all of the pin descriptions, just like in a standard XOD node.

Although adding descriptions is a bit tedious (especially for large nodes with many pins) it is a good habit to get in to as it will make the node a lot easier to use, especially months from now when you can’t quite remember what all of the pins are for!

We will be using this node in our robot project further on.

Adding Libraries

If you’ve used the Arduino IDE you’re likely aware of the concept of adding libraries to the IDE to support additional hardware and functions.  The same concept exists with XOD.

You can find the list of current XOD libraries on the XOD website Library page. As of this writing it’s not very extensive but it continues to grow as XOD users contribute libraries of their own.

In the next article in this series I’ll show you how you can create your own libraries and distribute them to other members of the XOD community.  However today we will just go over obtaining and installing a new library for your XOD IDE.

On the website the XOD libraries are listed in alphabetical order in the format “owner/libname” with a small description of the libraries function.  Clicking on a specific library brings up a page that details the library nodes and their functions.

Once you find a library that you want you’ll need to add it to the XOD IDE:

  1. Copy the libraries “owner/libname” string.
  2. Open the XOD IDE.
  3. Select File- Add Library from the top menu.
  4. A “Search Libraries” dialog box will be displayed.
  5. Enter the “owner/libname” string into the search box.
  6. The library will be displayed.
  7. Click on the library to add it to the XOD IDE.
  8. The library will be installed.

You’ll find the new library listed in your Project Explorer. It is now available for use with your project and with all future XOD projects you create.

H-Bridge Motor Control

The L298N H-Bridge motor controller will be used to control the two DC motors used in our robot car. Naturally to use this device we will need to find a node for it.

Searching through the list of installed nodes in the xod/common-hardware library reveals an H-Bridge controller, however this one is meant to be used with the discreet L298N integrated circuit and not with the commonly available modules. You’ll note that the H-Bridge used in this library has only one connection for motor direction while the common L298N modules have two.

There are actually a couple of ways around this. One of them is to use the existing H-Bridge library and modify the node to add an inverter and another input (the two direction pins are always at the opposite logic state so an inverter is all we would need to correct this).

However before we do this it is a good idea to see if someone has already created a XOD library with another H-Bridge node that supports both direction pins. And as luck would have it there is one.

The library at gweimer/h-bridge has a node called h-bridge-2dir which fits the description perfectly. So let’s grab that library and install in into our XOD IDE.

Follow the instruction above to install the library, use “gweimer/h-bridge” as the search term. Once you select it the library will be downloaded and installed into your XOD IDE.

Now that you have your new library let’s put it to use.

Open the gweimer/h-bridge library from your Project Explorer and select the h-bridge-2dir node (which in this library is the only node) and drag it onto your main patch.

The h-bridge-2dir node controls only one H-Bridge, the L298N actually is a dual H-Bridge. So make a copy of the node and paste it into your path so that you now have two nodes.

You’ll probably want to edit the nodes to distinguish the two motors, I named mine “Motor A” and “Motor B” but you may want to label them differently, it’s up to you.

<INSERT H-BRIDGE-2DIR DIAGRAM>

The h-bridge-2dir node has four pins, all inputs and all numbers:

  • DIR – The direction pin, usually connected to the IN2 (or IN4) line on the L298N module.
  • !DIR – The inverse direction pin, usually connected to IN1 (or IN3) line on the L298N module.
  • PWM – The PWM input, connected to ENA (or ENB on the L298N module.
  • SPD – The speed value. This is a number from -1 to 1 where 0 is stopped, 1 is full speed forward and -1 is full speed reverse.

If you have hooked up your motor controller as per the diagram I presented earlier then these are the values you need to use for your h-bridge-2dir nodes:

  • DIR Motor A – 4
  • !DIR Motor A – 2
  • PWM Motor A – 3
  • DIR Motor B – 8
  • !DIR Motor B – 7
  • PWM Motor B – 6

Enter those pin values and save your project.

Now select some values between -1 and 1 to enter into the SPD pins. Negative numbers make the motor spin in reverse.

Deploy your project to the Arduino. You should observe the motors rotating at the speed and direction you specified.

If you find that one of your motors is spinning in the opposite direction than what you programmed it to do it probably means you have the connections to the L298N backwards for that motor.  Reverse them to resolve the issue.

XOD Robot Control

So far we have seen how to control nodes for our H-Bridge motor controllers and the RGB LED. Now it’s time to expand upon our design to make our robot move and display it’s LED colors as per our instructions.

In its current iteration our robot car has no sensors so it can’t guilde itself by responding to sensor input.  Instead we need to give the robot a set of pre-programmed instructions and have it execute them.

As we develop our robot further we will add sensors and let the robot guide itself.

Sequential Programming

I’m using the term “Sequential Programming” loosely here, it basically means that I want the robot programmed to execute a sequence of commands when I start it up.

Essentially I want to be able to have a number of instructions that the robot will execute in a specific order. It will execute one instruction (i.e. “move forward for three seconds at full speed) and then when it is finished it will move on to another similar instruction (i.e. turn LED on Red for four seconds).  

I also want these instructions to repeat once they have finished. This is basically just like instructions in the ”loop” of a standard Arduino C++ program.

A key concept in XOD is the use of “pulses”, in the first article in this series we used a square-wave node to provide pulses to flash an LED.  Pulses are also the key to making our instructions run in a sequence.

What we need are nodes that accept a pulse, perform an action and then output a pulse that can be used in another node.

A good example of such a node is the xod/core/delay node.  This node has a SET input and a DONE output that work with pulses. Sending a pulse to the SET input causes the delay period to start. When it is done a pulse is sent out from the DONE pin.

SET and DONE are used in several nodes and we will also use them to develop custom sequential nodes for our robot car.

XOD Robot Code

In order to program our XOD robot we will need to build a couple of new custom “sequential” nodes. Each node will have a SET pulse input and a DONE pulse output.

One node will be for our LED and the other for our H-Bridge motor controller. We can then use as many copies of these nodes as we need to program the sequence that we wish our robot to perform.

As with our original RGB LED “custom node” we will be opening a new patch and using existing nodes to create our new “sequential” or “event” nodes.  Before we get started let’s take a look at some of the additional nodes we will need to create our new nodes.

Boot Node

The Boot Node could well be the simplest node in the entire XOD IDE, at least it’s certainly a contender for that title!

XOD boot node

This node literally has only one output – a pulse called boot.

The function of this node is to output a single pulse after the program starts.  Obviously this is ideal for sequencing our nodes.

We won’t use this node inside one of our custom nodes, it will be used in the main node to initiate the sequence we are building.  It can be found in the xod/core library.

Defer Pulse Node

There are a number of nodes that are described as “defer”, we will make use of Defer Pulse in both our custom nodes and in the main patch.

XOD defer-pulse node

All of the “defer” nodes have the same function. Each node has one input and one output. When a input is received (in our case an input pulse) the defer node will wait until all the current transactions are finished before passing that input to its output.

Defer nodes are often used to create feedback loops. The defer(pulse) node can be found in the xod/core library.

Delay Node

I mentioned the Delay Node earlier, it’s an important node that will be used in both of our new “sequential” nodes so it bears looking at further.

XOD delay node

The delay node has three input pins and two output pins:

  • T – A number pin, this sets the time of the delay measured in seconds.
  • SET – This is the SET pulse input that initiates the delay.
  • RST – A Reset pulse input that can cancel the delay.
  • ACT – A boolean (i.e. true-false) output. It is True during the delay period and then goes false.
  • DONE – The DONE pulse output, this is sent when the delay period is over.

We will use this node inside both of our new sequential nodes. It provides both the SET and DONE pulse input and output as well as an input (T) to set time. The ACT output will be used to control our new nodes.

Any Node

The Any Node is a pretty simple node. It has two inputs and one output, all of type pulse.

XOD any node

A pulse sent to either of the two inputs will result in a pulse from the houtput. It’s as simple as that!

The Any node is very useful for allowing a SET input to be links to more than one output. We wil do that when we run our sequence in a loop. Like the other nodes I just described the Any node can be found in the xod/core library.

LED Sequence Code

So let’s begin with our first “sequential” node, the one that controls our RGB LED.

Our new custom node will have the following input and output pins:

  • T – Time in seconds input. The length of time we want to turn on our RGB LED.
  • SET – SET Pulse input.  
  • R-PORT – The port number for the Red segment of our RGB LED.
  • R-LUM – The luminance value for the Red LED segment. Ranges from 0 to 1.
  • G-PORT – The port number for the Green segment of our RGB LED.
  • G-LUM – The luminance value for the Green LED segment. Ranges from 0 to 1.
  • B-PORT – The port number for the Blue segment of our RGB LED.
  • B-LUM – The luminance value for the Blue LED segment. Ranges from 0 to 1.
  • DONE – DONE Pulse output.

Operation of this node is pretty simple. We start by sending it a SET pulse. The node is then activated for the time period specified by the “T” value. During this time the RGB LED will glow with the colors and intensities specified in the R-LUM, G-LUM and B-LUM values.  When the time period has expired the RGB LED will be turned off and the node will emit a DONE pulse.

XOD event-rgb-led-display patch

Follow these steps and the diagram above to create your new node. Note that I am naming it event-rgb-led-display, the term “event” is to specify that this node is not constantly activated but is instead an event in time. You cabn, of course, name it anything you wish.

  • Create a new patch (File – New Patch or Ctrl+N).
  • Name patch event-rgb-led-display.
  • Add rgb-led node (from the patch you created earlier).
  • Add core/delay node.
  • Add patch-nodes/input-pulse node.
  • Link input pulse node to delay node SET input
  • Edit new patch-nodes/input-pulse node:
    • Name: SET
    • Description – copy from “delay” node SET description
  • Add patch-nodes/input-number node.
  • Make 6 more copies of input-number node.
  • Link original input number node to delay node T input.
  • Edit original patch-nodes/input-number node:
    • Name : T
    • Description – copy from “delay” node T description
  • Add 3 core/if-else nodes
  • Link R output from each if-else node to “LUM” inputs on rgb-led node
    • R to R-LUM
    • R to G-LUM
    • R to B-LUM
  • Link input-number node to R-PORT input on rgb-led node
  • Edit input-number node:
    • Name: R-PORT
    • Description – copy from “rgb-led” node R-PORT description
  • Link input-number node to G-PORT input on rgb-led node
  • Edit input-number node:
    • Name: G-PORT
    • Description – copy from “rgb-led” node G-PORT description
  • Link input-number node to B-PORT input on rgb-led node
  • Edit input-number node:
    • Name: B-PORT
    • Description – copy from “rgb-led” node B-PORT description
  • Linkt input-number node to T input on first if-else node
  • Edit input-number node:
    • Name: R-LUM
    • Description – copy from “rgb-led” node R-LUM description
  • Link input-number node to T input on second if-else node
  • Edit input-number node:
    • Name:G-LUM
    • Description – copy from “rgb-led” node G-LUM description
  • Link input-number node to T input on third if-else node
  • Edit input-number node:
    • Name: B-LUM
    • Description – copy from “rgb-led” node B-LUM description
  • Link ACT output of delay node to COND inputs on all three if-else nodes
  • Add core/defer pulse node.
  • Link DONE output on delay node to IN input on defer node.
  • Add patch-nodes/output-pulse node.
  • Link OUT output from defer node to output-pulse node.
  • Edit patch-nodes/output-pulse node:
    • Name: DONE
  • Save project

Now that you’ve built your new RGB LED Display it’s time to put it to the test.

Go back into the main patch. If you have any nodes or links still left in the main patch then delete them.

In your Project Explorer you will now see your event-rgb-led-display patch. Drag it onto the main patch and look at it’s properties.

Fill in the values for R-PORT, G-PORT and B-PORT, they are the same as the values you used for the original RGB LED node you built.  Select a period of time (in seconds) that you wish to illuminate the RGB LED and set the R-LUM, G-LUM and B-LUM values to the color levels you desire.

Now take a core/boot node (the one we described earlier) and add it to the main patch. Connect its output to the SET input on your new event-rgb-led-display node.

Save the project and then deploy it to your Arduino on the robot.

You should see the LED illuminate for the time you specified and at the color combination you chose.

Now make a few copies of your new node, I made two when I did this.  Go into each node and set the LUM and T values to be different than the original. The PORT values will be correct as this is a copy of a node you already configured.

Chain your nodes together by linking the DONE output of one node to the SET input on the next one. Then save and deploy your project.

You should see the RGB LED sequence working.

In some cases you may NOT get the first sequence, I ran into that a few times. The solution seems to be to add a defer(pulse) node between the boot node and the first event-rgb-display node.

Working in a Loop

The program we just ran did exactly what we wanted, it illuminated the RGB LED for a period of time. Then it finished.  

This is the same effect you would have using the regular Arduino IDE and placing all of your code in the setup function and none in the loop.  And for some applications it’s exactly what we want to do.

However many times we want our code to continuously run, just as if it were in the loop in a Arduino C++ program.

You can’t just connect the DONE output of the final event-rgb-led-display node to the SET input of the first one, trying to do that will result in an error as XOD does not allow multiple connections to an input pin.

Sounds like a job for the any node!  Get one from your xod/core library and place it on your main patch, close to the boot node.

Connect your final DONE output to a defer(pulse) node input. Connect the defer(pulse) output to one of the any node inputs.

Now break the link between the boot node output and the first event-rgb-led-display node SET input.  Connect the output of the boot node to the remaining input on the any node. Connect the output of the any node to the SET input on the first event-rgb-led-display node.

Save the project and deploy it.

Your RGB LED should now display the sequence continuously.

We can use a similar technique to create a sequential node for our H-Bridge motor controller.

Motor Sequence Code

We will now do pretty well the same thing we did for our RGB LEDs for our motors. In fact the design is almost identical.

Our motor sequence node, which I am calling event-motor-move, will have the following pins:

  • T – Time in seconds for the motors to run.
  • SET – The SET input to start the motors running.
  • DIR-A – The DIR pin for Motor B. You could also label this IN2 if you like.
  • !DIR-A – The !DIR pin for Motor B. You could also label this IN1 instead to match your L298N motor controller.
  • PWM-A – The PWM pin for Motor A. You could also label this ENA.
  • SPD-A – The speed value for Motor A, a value from -1 to 1.
  • DIR-B – The DIR pin for Motor B. You could also label this IN4 if you like.
  • !DIR-B – The !DIR pin for Motor B. You could also label this IN3 instead to match your L298N motor controller.
  • PWM-B – The PWM pin for Motor B. You could also label this ENB.
  • SPD-B – The speed value for Motor B, a value from -1 to 1.
  • DONE – The output pin for the DONE pulse.

XOD event-motor-move patch

To construct this node follow the diagram and/or the steps below.

  • Create a new patch (File – New Patch or Ctrl+N).
  • Name patch event-motor-move.
  • Add 2 gweimer/h-bridge/h-bridge-2dir nodes (from the library you downloaded earlier).
  • Label one h-bridge node “Motor A”.
  • Label second h-bridge node “Motor B”.
  • Add core/delay node.
  • Add patch-nodes/input-pulse node.
  • Link input pulse node to delay node SET input
  • Edit new patch-nodes/input-pulse node:
    • Name: SET
    • Description – copy from “delay” node SET description
  • Add patch-nodes/input-number node.
  • Make 8 more copies of input-number node.
  • Link original input number node to delay node T input.
  • Edit original patch-nodes/input-number node:
    • Name : T
    • Description – copy from “delay” node T description
  • Add 2 core/if-else nodes
  • Link R output from each if-else node to “SPD” inputs on rgb-led node
    • R to SPD on Motor A
    • R to SPD on Motor B
  • Link input-number node to DIR input on Motor A node
  • Label input number node:
    • Name: DIR-A
    • Description; Copy description from Motor A node DIR pin.
  • Link input-number node to !DIR input on Motor A node
  • Label input number node:
    • Name: !DIR-A
    • Description; Copy description from Motor A node !DIR pin.
  • Link input-number node to PWM input on Motor A node
  • Label input number node:
    • Name: PWM-A
    • Description; Copy description from Motor A node PWM pin.
  • Link input-number node to DIR input on Motor B node
  • Label input number node:
    • Name: DIR-B
    • Description; Copy description from Motor B node DIR pin.
  • Link input-number node to !DIR input on Motor B node
  • Label input number node:
    • Name: !DIR-B
    • Description; Copy description from Motor B node !DIR pin.
  • Link input-number node to PWM input on Motor B node
  • Label input number node:
    • Name: PWM-B
    • Description; Copy description from Motor B node PWM pin.
  • Link input-number node to T input on first if-else node
  • Label input number node:
    • Name: SPD-A
    • Description; Copy description from Motor A node SPD pin.
  • Link input-number node to T input on second if-else node
  • Label input number node:
    • Name: SPD-B
    • Description; Copy description from Motor B node SPD pin.
  • Connect COND inputs on both if-else nodes to ACT output on delay node.
  • Add core/defer pulse node.
  • Link DONE output on delay node to IN input on defer node.
  • Add patch-nodes/output-pulse node.
  • Link OUT output from defer node to output-pulse node.
  • Edit patch-nodes/output-pulse node:
    • Name: DONE
  • Save project

Now go back to your main patch and drag a new event-motor-move node onto it. Fill in the values for the connections to the L298N H-Bridge.  Also set some speed and time values.

XOD main patch

Link one of the DONE outputs from one of the event-rgb-led-display nodes to the SET input of your event-motor-move node. Link the output to another event-rgb-led-display node.

You can make copies of the new node, change their values and link them into the sequence.

When you are done save the project and deploy it to the robot. Make sure the robot car is in a place where you can actually run it, or lift it off the workbench so that it doesn’t run away on you!

Your XOD powered robot car can now run around the room!

Conclusion

As this article and its associated video have hopefully illustrated it is possible to create complex projects using XOD without your screen becoming as complex as a map of Manhattan!

I hope you decide to build the XOD robot and stay tuned for more installments, as I think it will be a really fun project.

Let me know about your XOD projects in the comments below. Happy Xoding!

Resources

XOD Website – The XOD website, the primary source for information regarding XOD.

Code from this Article – The .xodball files I used in this article, in a convenient ZIP file for you!

XOD Libraries – The XOD Library page.

Getting Moving with XOD – Robot Car Part 1
Summary
Getting Moving with XOD - Robot Car Part 1
Article Name
Getting Moving with XOD - Robot Car Part 1
Description
Learn more XOD coding. We will discuss programs with multiple patches, custom nodes and using XOD libraries. We will also start our new XOD project - a XOD-based robot car.
Author
Publisher Name
DroneBot Workshop
Publisher Logo
Subscribe
Notify of

5 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Kevin Pearce
6 years ago

Hi Bill, I thoroughly enjoy watching your u-tube demonstrations about all things Arduino. In particular, I have recently been following your Arduino Programming with XOD #2 – Robot Car video. Although I have made all the nodes you discuss there, I am wondering where I can download the files that you state. Under your Conclusion / Resources: XOD Website – The XOD website, the primary source for information regarding XOD. Code from this Article – The .xodball files I used in this article, in a convenient ZIP file for you! XOD Libraries – The XOD Library page. The middle item… Read more »

Alan
5 years ago

Blown away! Best series of instructional’s I haver ever watched. I now better understand the XOD.
Keep up the good work.
Alan

Peter
5 years ago

Dear Bill, just wanted to congratulate you on your superb series of tutorials.They are, clear, succinct and informative. Your wiring diagrams are a masterstroke…showing the actual components provides a dimension of understanding not often found in a tutorial context. Whilst I don’t do any electronics, (I don’t own a screwdriver let alone an Arduino), I’ve watched many of your vids and found them, without exception, informative and entertaining. So much so that I might just start playing the electronics gsmr. Thankyou so much for your time and effort snd I look forward to the next exciting post..

yusif
3 years ago

Hello and thankyou for perfect site
i cant use DHT11orDHT22 sensor on XOD software please make a project about it

John Clements
2 years ago

I am really enjoying following you XOD tutorials. I had intended on traveling when I finely retired in Jan 2020, but instead found myself staying at home so reverted to my old hobby of electronics and combined it with my profession (computer science) and started building robots for fun. Thank you.