Introduction: 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!
Step 1: Components
- One Arduino compatible board (I use Arduino Nano, because I have one, but any other will be just fine )
- One Joystick that I got from this cheap 37 sensors set.
- 2 Small Servos
- 2 Male-Female jumper wires
- 5 Female-Female jumper wires
- One K2 Breadboard power supply with adapter
Step 2: Connect the Servos to the Power
- 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
Step 3: Connect the Servos to Arduino
- 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
Step 4: Connect the Joystick to Arduino
- 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
Step 5: Start Visuino and Select the Arduino Board Type
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.
Step 6: In Visuino: Add Servo Components, and Connect Them to the Arduino Digital Pins
- 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)
Step 7: In Visuino: Connect the Servo Components to the Arduino Analog Pins
- 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)
Step 8:
- 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)
Step 9: And Play...
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