How to Write an Ardulink GUI, to Control Arduino




About: I was born in Rome in 1972. I have a degree in computer science but I am continuing to study it. My interest in this has also become my profession and I work for a IT multinational company. The most importan...

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:

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

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);



Be the First to Share


    • Instrument Contest

      Instrument Contest
    • Make it Glow Contest

      Make it Glow Contest
    • STEM Contest

      STEM Contest

    14 Discussions


    2 years ago

    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

    1 reply

    Reply 2 years ago

    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:


    3 years ago

    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.

    1 reply

    Reply 3 years ago 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


    3 years ago

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

    Paul RyanD

    3 years ago

    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..

    1 reply

    3 years ago

    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

    1 reply

    Reply 3 years ago

    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.


    3 years ago

    on arduino wich .ino file i have to upload


    4 years ago on Introduction

    I used to program in java and had my own application for microcontrollers ( PIC was the go to one before the arduino ). What you have done here is so much more ambitious, I am very impressed. I could never really get the Java GUI components under control. Now I have moved to Python and would recommend it, not necessarily as a replacement for Java but as a different type of language with its own strengths and differences, unlike C++ and Java, it is really different from Java. There are also environments that make them play together nicely ( in theory, I have not tried it ).

    You have also figured out how to put code really nicely in an instructable, why not write a short one on that.

    Finally there is no justice on instructables, this is among say the best 10% of all technical instructables published, yet its views languish. In some cases this is because it is a good instructable, TLDR. Please keep publishing, maybe dumb it down a little. If you take a look at my instructables you will see, I think, that views are not well correlated with intrinsic quality or effort. I publish frequently even when I know the views will be low.

    1 reply

    Reply 4 years ago on Introduction

    Thank you, I'm very happy when someone likes my work. I agree about languages. Each language has its strengths and its weaknesses. They are just tools. I mean, it is very difficult to cut down a tree with a scalpel as it is very difficult to operate with a saw. So we should ever use the right tool for a given work.

    Actually I don't know Python but I know it's a powerful language.

    I'll try to add some instructable when I'll have the time for. Maybe that one of them will be famous!

    I'll try to improve Ardulink. Java libraries can be extended a lot with a lot of Technologies. Maybe that Ardulink will have also a web interface in the future.


    Reply 6 years ago on Introduction

    Thank you. Let me know if you'll find some issues.