Arduino And Visuino: Control Servos With A Joystick

About the project

Controlling Servos connected to Arduino with Joystick is very common task. With Visuino, achieving this has never been easier!

Project info

Difficulty: Easy

Platforms: ArduinoVisuino

Estimated time: 1 hour

License: GNU General Public License, version 3 or later (GPL3+)

Items used in this project

Hardware components

Jumper wires (generic) Jumper wires (generic) x 1
Joystick module Joystick module x 1
Servos (Tower Pro MG996R) Servos (Tower Pro MG996R) x 2
Arduino Nano R3 Arduino Nano R3 I use Arduino Nano, because I have one, but any other will be just fine. x 1

Software apps and online services

Arduino IDE Arduino IDE
Visuino - Graphical Development Environment for Arduino Visuino - Graphical Development Environment for Arduino

Story

Controlling Servos connected to Arduino with Joystick is very common task. With the help of Visuino, an easy to use graphical development environment for Arduino, achieving this has never been easier!

Components

1 / 2Picture 1

Picture 1

Picture 1

Picture 2

Picture 2

  • One Arduino compatible board (I use Arduino Nano, because I have one, but any other will be just fine)
  • 2 Male-Female jumper wires
  • 5 Female-Female jumper wires

Connect the Servos to the Power

1 / 3Picture 1

Picture 1

Picture 1

Picture 2

Picture 2

Picture 3

Picture 3

  • Connect the Male end of the Male-Female jumper wires to the Control wires of the Servos as shown on Picture 1
  • Connect the Servo connectors to the K2 Power Supply in such a way that the Ground of the Power Supply is connected to the Groundwire of the Servo, and the Power of the Power Supply to the Powerwire of the Servo as shown on Picture 2, and 3
  • Make sure the power supply is set to 5V

Connect the Servos to Arduino

1 / 4Picture 1

Picture 1

Picture 1

Picture 2

Picture 2

Picture 3

Picture 3

Picture 4

Picture 4

  • Connect a Female-Female wire (Black wire) to the Ground of the Power Supply as shown on Pictures 1 and 2
  • Connect the other end of the Ground wire (Black wire) to the Ground pin of the Arduino (Picture 3)
  • Connect the Signal wire (Yellow wire) from one of the Servos to Digital pin 2 of the Arduino (Picture 3)
  • Connect the Signal wire (Orange wire) from the other Servo to Digital pin 3 of the Arduino (Picture 3)
  • Picture 4 shows the Arduino Nano pins that ware connected in this step

Connect the Joystick to Arduino

1 / 3Picture 1

Picture 1

Picture 1

Picture 2

Picture 2

Picture 3

Picture 3

  • Connect Female-Female wires to the Ground (Black wire), Power (Red wire), VRx (White wire), and VRy (Brown wire) of the Joystick as shown in Picture 1
  • Connect the Ground wire (Black wire) to the Ground pin of the Arduino board (Picture 2)
  • Connect the Power wire (Red wire) to the 5V Power pin of the Arduino board (Picture 2)
  • Connect the VRx wire (White wire) the the Analog 1 pin of the Arduino board (Picture 2)
  • Connect the VRy wire (Brown wire) the the Analog 0 pin of the Arduino board (Picture 2)
  • Picture 3 shows the Arduino Nano pins that ware connected in this step

Start Visuino and select the Arduino Board type

1 / 2Picture 1

Picture 1

Picture 1

Picture 2

Picture 2

To start programming the Arduino, you will need to have the Arduino IDE installed from here: http://www.arduino.cc/ .

Please be aware that there are some critical bugs in Arduino IDE 1.6.6. Make sure that you install 1.6.7 orhigher, otherwise this Tutorial will not work!

The Visuino: https://www.visuino.com also needs to be installed.

  • Start Visuino as shown in the first picture
  • Click on the "Tools" button on the Arduino component (Picture 1) in Visuino
  • When the dialog appears, select Arduino Nano as shown in Picture 2

In Visuino: Add Servo components, and connect them to the Arduino Digital pins

1 / 3Picture 1

Picture 1

Picture 1

Picture 2

Picture 2

Picture 3

Picture 3

  • Type "ser" in the Filter box of the Component Toolbox then select the "Servo" component (Picture 1), and drop two of them in the design area
  • Connect the "Out" pin of the Servo1 component to the "Digital" input pin of "Digital[ 2 ]" channel of the Arduino component (Picture 2)
  • Connect the "Out" pin of the Servo2 component to the "Digital" input pin of "Digital[ 3 ]" channel of the Arduino component (Picture 3)

n Visuino: Connect the Servo components to the Arduino Analog pins

1 / 4Picture 1

Picture 1

Picture 1

Picture 2

Picture 2

Picture 3

Picture 3

  • Connect the "In" pin of the Servo1 component (Picture 1) to the "Out" pin of "Digital[ 14 ]/AnalogIn[ 0 ]" channel of the Arduino component (Picture 2)
  • Connect the "In" pin of the Servo2 component (Picture 3) to the "Out" pin of "Digital[ 15 ]/AnalogIn[ 1 ]" channel of the Arduino component (Picture 4)

Generate

1 / 2Picture 1

Picture 1

Picture 1

Picture 2

Picture 2

  • In Visuino, Press F9 or click on the button shown on Picture 1 to generate the Arduino code, and open the Arduino IDE
  • In the Arduino IDE, click on the Upload button, to compile and upload the code (Picture 2)

And play...

1 / 2Picture 1

Picture 1

Picture 1

Picture 2

Picture 2

Picture 1 shows the connected and powered up project.

If you move the Joystick Left-Right, and Up-Down the Servos will follow the movements.

Congratulations! You are now in control of your Servos!

On Picture 2 you can see the complete Visuino diagram.

Also attached is the Visuino project, that I created for this Tutorial. You can download and open it in Visuino: https://www.visuino.com

Credits

Photo of Ron

Ron

Arduino Developer

   

Leave your feedback...