1. Home
  2. Docs
  3. Niryo one
  4. Tutorials
  5. Control the Niryo One with an Arduino Board

Control the Niryo One with an Arduino Board


There are endless programming activities you can do with Niryo One. Programming the robot from an Arduino board is one of those. In this tutorial we’ll go through a real life example to show you how to do that.

The concept

Using an Arduino board along with one (or many) Niryo One will allow you to create more complex applications. For example, you can easily setup a small assembly line demo with just one Arduino and 2 robots.

Let’s just start with one Arduino and one robot.

The concept is simple :  the Arduino board is the Master which decides which robot does what. It received data from sensors or user input, and sends different commands to the robots via digital pins. To start a command on a robot, the Arduino will send a digital signal. It will have to wait for a response (another digital signal on another pin) to know that the robot has finished.

Each robot is a slave. It has some predefined set of commands, and wait for the Arduino to send it a digital signal. Upon reception of the signal, a given command is started, and once finished, the robot will send another digital signal to the Arduino, to notify it has finish the command execution.

Electrical setup

Before powering anything on, make sure that the robot and the Arduino share a common ground (black wire).

Then, you can plug up to 6 wires on the 6 digital pins at the back of the robot. On the Arduino, plug those wires on digital pins. You will then have to choose which pins are set as INPUT and OUTPUT. (Choose appropriate colors to avoid mistakes in the future)

In this example, we are using 3 wires : 2 for sending commands from the Arduino to the robot (Arduino : OUTPUT, robot : INPUT), and 1 for sending back the command execution confirmation (Arduino : INPUT, robot : OUTPUT). You will need to remember what you chose in the setup for writing the code of the application.

We’ve also added 2 buttons with 10kOhm pull-down resistors, so the user will be able to choose to execute the action “pick”, or “place”.

Programming the robot with Niryo Blocks (Niryo One Studio)

In this example, we define 2 functions, “Pick” and “Place”. The “Pick” function will pick an object (using the large gripper) on the left of the robot, and the “Place” function will place the object on the right of the robot.

First, we set the pins 1A and 1B as INPUT, to receive a signal from the Arduino. The pin 1C is set as OUTPUT, to send a signal back upon command completion.

We then add an infinite loop reading the 2 pins set as INPUT. If one pin receives a HIGH signal, the associated command will be started. At the end of the command, the pin set as OUTPUT on the robot will send a HIGH signal for 0.2 seconds (so the Arduino has the time to process it) and then set it back to LOW.

You can download the XML used to create this sequence. All you need to do is to import this sequence in the Niryo Blocks tab of Niryo One Studio, and run the sequence on the robot.

The Arduino code

Download the Arduino code here.

Going further

What you’ve seen here is the foundation for programming Niryo One robots with Arduino boards. You can easily scale the application with more robots, more Arduinos, more sensors, more buttons, etc…

The Niryo Block structure you’ve seen here will be pretty much the same : a loop that waits for a signal from the Arduino board, executes a command, and sends back a response.

Now, with your imagination (and a little bit of work), you could create some nice applications. Just a few ideas

  • Tic tac toe : robot vs human
  • Assembly line that separates objects depending on their weight (along with a connected Arduino-balance)
  • Robot gives chocolate to the user when the user presses a button

If you build a nice application with Niryo One and Arduino (or any other electrical board), feel free to share it with the Niryo community on the social networks with #niryo. We’d be glad to feature your project 🙂

How can we help?