How to Write an Ardulink GUI, to Control Arduino





Introduction: How to Write an Ardulink GUI, to Control Arduino

In this tutorial you can read how to write, just in 10 steps, an Ardulink GUI like the one shown here. You need just five minutes to follow a video tutorial and just five minutes to read this tutorial.

Ardulink is a java open source library and/or a ready swing application able to control Arduino. Ardulink is a project of mine.

You can find more details about Ardulink here:

Step 1: Is You a Developer or an User?

Ardulink has a ready application called Ardulink Console with all swing components. So if your aren't interested in develop your own interface then you can use Ardulink Console as is.

Step 2: Ok, You Are a Developer

You can see the full five minutes video tutorial on youtube by following this link:
Now you can download the eclipse (kepler) workspace with the tutorial code following this link (the original tutorial):

I used two Ardulink components and a simple SWING button.
  • org.zu.ardulink.gui.ConnectionPanel is able to search for serial ports connected to the Arduino and select one.
  • org.zu.ardulink.gui.PWMController is able to manage the power with modulation Arduino's pins.
  • The button handles the event for the connection.
To have a GUI like the one in this tutorial you only need to:
  • Use a JFrame (steps: 1,2 and 3)
  • Add inside a org.zu.ardulink.gui.ConnectionPanel (step 4)
  • Add a JButton (step 5)
  • Add inside a org.zu.ardulink.gui.PWMController (step 6)
  • Use a JButton to invoke the org.zu.ardulink.Link class (steps: 7, 8, 9 and 10)
The most important instruction of this tutorial is in fact:
boolean connected = Link.getDefaultInstance().connect(connectionPort, baudRate);

Using the default connection method Link class initializes a dialogue with Arduino board connected to a specific serial port with a given baud rate.
Here the source code:

package org.zu.ardulink.tutorial;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;

import org.zu.ardulink.Link;
import org.zu.ardulink.gui.ConnectionPanel;
import org.zu.ardulink.gui.PWMController;


public class Tutorial1 extends JFrame {

   private static final long serialVersionUID = -5884548646729927244L;

   // 2. Define the contentPane and an ardulink connection panel
   private JPanel contentPane;
   private ConnectionPanel connectionPanel;

    * Launch the application.
   public static void main(String[] args) {
     EventQueue.invokeLater(new Runnable() {
       public void run() {
         try {
           // 1. Change Look and Feel

           Tutorial1 frame = new Tutorial1();
         } catch (Exception e) {

    * Create the frame.
   public Tutorial1() {
     setBounds(100, 100, 475, 375);
     // 3. Setup the contentPane
     contentPane = new JPanel();
     contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
     contentPane.setLayout(new BorderLayout(0, 0));

     // 4. Insert the defined connection Panel
     connectionPanel = new ConnectionPanel();
     contentPane.add(connectionPanel, BorderLayout.WEST);

     // 5. Insert a connection button
     JButton btnConnect = new JButton("Connect");
     // 7. Add an action listener when the connection button is pressed
     btnConnect.addActionListener(new ActionListener() {
       public void actionPerformed(ActionEvent e) {
         // 8. Take connection parameters
         String connectionPort = connectionPanel.getConnectionPort();
         int baudRate = Integer.parseInt(connectionPanel.getBaudRate());

         // 9. Let's go. Link it to Arduino.
         boolean connected = Link.getDefaultInstance().connect(connectionPort, baudRate);

         // 10. Just an information message
         if(connected) {
           JOptionPane.showMessageDialog(connectionPanel, "Arduino connected", "Connection Status", JOptionPane.INFORMATION_MESSAGE);
         } else {
           JOptionPane.showMessageDialog(connectionPanel, "Arduino NOT connected", "Connection Status", JOptionPane.ERROR_MESSAGE);

     contentPane.add(btnConnect, BorderLayout.SOUTH);

     // 6. Insert an ardulink power with modulation pin controller
     PWMController powerPinPanel = new PWMController();
     contentPane.add(powerPinPanel, BorderLayout.EAST);





    • Pocket-Sized Contest

      Pocket-Sized Contest
    • Pro Tips Challenge

      Pro Tips Challenge
    • Paper Contest 2018

      Paper Contest 2018

    We have a be nice policy.
    Please be positive and constructive.




    first of all you didn't mentioned how to import the libraries and resource file and directly jumped to code. i am having a trouble with the resource file where i can find them. not a good tutorial


    Maybe. This is a tutorial I wrote some years ago. I think that I should write other tutorials since Ardulink users need for more information about it. Actually Ardulink is a maven project and its artifacts are available on maven central ( so you should be able to understand which artifacts are needed.

    A good point to start to study how write your own project is Ardulink Console you can find the code here:


    Yes, of course, you can with Ardulink. Here a GUI example with a textbox:

    It uses this GUI widget:

    but there is also this one:

    These components have a textfield and a button. When you press the button a custom message with text value from the textfield is sent to Arduino.

    I have used it in the SimpleSmartCarDriver example that you can find in the Ardulink distribution. not a programmer but using your instructions i have successfully made a single tabbed real time chart ,plotting single analog value,but i want add another tab in to give a digital input and analog input to the arduino. please guide me .thanks for the help

    Hello, is it possible to build a GUI to control 3 servo motors independently?

    Hi I would like to ask, is it possible to make GUI for arduino with input textbox? I often see GUI with slider only.. My project is all about monitoring the weight of a ship as load is being loaded, it also comes with sensor, and height of the ship is one of the varibales in the formula. so I need to create a GUI in order to tell an arduino what is the height of the ship, and at the same time outputs also in the PC the weight of the ship, in continous time. Thanks..

    Can anyone please advise? I receive the following error when I am running the code.

    java.lang.UnsatisfiedLinkError: Can't load IA 32-bit .dll on a AMD 64-bit platform thrown while loading

    Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: Serial.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform


    Ardulink 1 uses mainly RXTX library to connect PC with Arduino. This library isn't a java pure library and needs for a shared object (dll for windows users) installed on the PC. Of course this shared object has to be compatible with the system architecture. So you have to replace the DLL 32 bit with the 64 bit one. You can find both library version into Ardulink distribution. You can put the right one into windows folder or into the working directory of your application.

    on arduino wich .ino file i have to upload