Arduino Nano and Visuino: Control Servos With Joystick

by BoianM in Circuits > Arduino

15264 Views, 153 Favorites, 0 Comments

Arduino Nano and Visuino: Control Servos With Joystick

Arduino Nano and Visuino: Control Servos with Joystick

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!

Please note that the annotation on some of the pictures in this Instructable will work correctly on some browsers only after you click on the image to expand it.

Please make sure you click on the image to see the annotation showing the correct spot on the image!

Components

56761f084fbade6071000ac0.jpeg
56761f204fbade6071000ac3.jpeg
  1. One Arduino compatible board (I use Arduino Nano, because I have one, but any other will be just fine )
  2. One Joystick that I got from this cheap 37 sensors set.
  3. 2 Small Servos
  4. 2 Male-Female jumper wires
  5. 5 Female-Female jumper wires
  6. One K2 Breadboard power supply with adapter

Connect the Servos to the Power

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

Connect the Servos to Arduino

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

Connect the Joystick to Arduino

DSC02487.JPG
DSC02498.JPG
JoistickPins.png
  1. 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
  2. Connect the Ground wire(Black wire) to the Ground pin of the Arduino board (Picture 2)
  3. Connect the Power wire(Red wire) to the 5V Power pin of the Arduino board (Picture 2)
  4. Connect the VRx wire(White wire) the the Analog 1 pin of the Arduino board (Picture 2)
  5. Connect the VRy wire(Brown wire) the the Analog 0 pin of the Arduino board (Picture 2)
  6. Picture 3 shows the Arduino Nano pins that ware connected in this step

Start Visuino and Select the Arduino Board Type

SelectBoard.png
SelectBoard.png

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 or higher, otherwise this Instructable will not work!

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

  1. Start Visuino as shown in the first picture
  2. Click on the "Tools" button on the Arduino component (Picture 1) in Visuino
  3. 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

ComponentServo.png
ComponentServoConnect1.png
ComponentServoConnect2.png
  1. 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
  2. Connect the "Out" pin of the Servo1 component to the "Digital" input pin of "Digital[ 2 ]" channel of the Arduino component (Picture 2)
  3. Connect the "Out" pin of the Servo2 component to the "Digital" input pin of "Digital[ 3 ]" channel of the Arduino component (Picture 3)

In Visuino: Connect the Servo Components to the Arduino Analog Pins

ComponentServoConnect3.png
ComponentServoConnect4.png
ComponentServoConnect5.png
ComponentServoConnect6.png
  1. 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)
  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)

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

And Play...

DSC02507.JPG
VisuinoDiagramCropped.png

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 Instructable. You can download and open it in Visuino: https://www.visuino.com