Introduction: Controlling Servos With Joystick (Arduino)

Hey guys -

I hope you're staying well and healthy. The recent global crisis has me thinking a lot about biological determinism and the ability to map our bodies, our surroundings, and our future. I think there's something pretty fascinating in mapping/contouring so in this project I'm going to go over some prototyping that I think will be able to preface a larger project in XYZ-coordinate mapping methods.

Here's a fun project you can do that doesn't require a lot of equipment!


FYI - I am in the process of building a sort of rickety prototype as in the picture of the Earth hole. Those parts are optional:

Aluminum, steel, epoxy, shovel

Supplies

1x Arduino Uno R3 (I got mine from Amazon)

2x Servo Motors (I am using a Micro Servo)

1x Joystick Module

9V Battery

Wires & Breadboard

Step 1: Putting It Together

Being able to control two (or one) servos with a joystick allows for an increased range of motion. Your joystick—acting as two potentiometers controlling an x- and a y-plane—will act as input to the servos. This results in a fluid motion like a laser controller.

Please note: for clarity, I have color-coded two basic wiring connections. Ground connections are black wires; voltage connections are red wires.

Also, I am only working with one servo in this Instructable and won't be using the Switch on the joystick, so keep that in mind. However, I have included steps to wire in a second servo (I just don't have a second servo with me, sorry), which will be shown in the images as well. Just no physical second servo; the wires will be pinned into the carpet instead. *shrugs*

Connections:

The external battery VCC / GND connect to the breadboard

The Arduino GND connect to the breadboard's GND input

The Servo VCC and GND connect to the breadboard's VCC / GND inputs

The Servo1 Signal connects to the Arduino Digital PWM 3

The Servo2 VCC and GND connect to the breadboard's VCC / GND inputs

The Servo2 Signal connects to the Arduino Digital PWM 5

Step 2: The Joystick Module

OKAY! Here comes the fun part.

The joystick module has two potentiometers for reading the x- and y-position (with values ranging from 0-1023 which will be displayed within the serial monitor when you upload the code).

There is also one switch which is activated if you press down onto the joystick module.

The joystick module has 5 pins: +5Vcc - GND - VRx - VRy - SW

Connections:

The Joystick GND connect to the Arduino GND

The Joystick VCC connect to the Arduino VCC

The Joystick 'X' connects to the Arduino Analog 0

The Joystick 'Y' connects to the Arduino Analog 1

The Joystick 'SW' (switch or button) not connected

Step 3: Coding

Code here:

https://github.com/MertArduino/Multiple-Servo-Moto...

It might help to have some knowledge of slope formulas if you want to go more advanced with the coding.

Have fun! And thanks for reading. :) I think besides the applications in robotic arms, lasers, vending toy machines, I think this is a great start to thinking about how to carve reliefs into the Earth, much like a ginormous XYZ-plotter.

Many thanks for the help: