Project Description

TUTORIAL

Dual Axis Camera Slider using Joystick IN and OUT

Dual Axis Camera Slider using Joystick to set IN and OUT Points

VIDEO

PARTS USED

Available in the Brainy-Bits store

OVERVIEW

In our prior tutorial we saw how to control 2 stepper motor simultaneously using the Arduino Serial Monitor.

 

You can check out that tutorial here:  2 axis Camera Slider Tutorial

 

Continuing from this, we will now add an Analog Joystick to our project to set IN and OUT points for the Steppers to travel to.

 

We will also be seeing a new way to move both steppers simultaneously and make sure that they reach their destination at the same time.

 

Again we will be using the Serial Monitor to input some values like the Speed we want the Steppers to travel but we will also be using the Joystick integrated switch to set the IN and OUT points.

SCHEMATIC

Arduino Camera Slider

The connection for the Easy Driver boards are almost the same as our prior tutorial:

 

To power the Stepper Motors connected to the Easy Driver boards we are using a 12V 1A power supply.

 

The GND and 5V (out) of the Power Supply are connected to the breadboard power rails.
GND and 5V (in) of the Easy Driver boards are connected to the breadboard power rails.

 

Each pair of winding of the Stepper motors are connected to the A-B pins of the Easy Drivers.

 

The GND of the UNO is connected to the breadboard GND power rail.

Each Easy Driver GND is connected to the breadboard GND power rail.

 

Pin 3 and 4 of the UNO are connected to the STEP and DIR pins of one Easy Driver.

Pin 6 and 7 of the UNO are connected to the STEP and DIR pins of the other Easy Driver.

 

In this tutorial we added these connections for the Analog Joystick:

 

GND of the Joystick is connected to the GND of the UNO.

V+ of the Joystick is connected to the 5V of the UNO.

 

The X and Y axis Pins of the Joystick are connected to Pins A0 and A1 of the UNO.

 

The Switch Pin of the Joystick is connected to Pin 2 (Interrupt zero) of the UNO.

THE CODE

The code we are using is different from our prior tutorial, but we are using some parts of it to read data from the Serial Monitor.

 

We are still using the AccelStepper class of the library to move the Steppers using the Joystick X and Y axis.

 

But we are now using the MultiStepper class of the same library to move both Steppers once we have set the IN and OUT points using the Joystick.

 

The MultiStepper class not only provide us with a way to move both Steppers at once, but also calculates the speed needed to move each Steppers so they end up at their destination (IN or OUT point) at the same time.

 

We use the Serial Monitor window to provide us with information like what the sketch is expecting at a particular point as well as give us the ability to enter information like the desired Speed and what move we want to execute.

 

As always, Don’t forget to watch our Tutorial video for more information.

 

 

DOWNLOAD

Copy the above Sketch code in your Arduino IDE software to program your Arduino.

 

Used Libraries:

Download The AccelStepper Library

created by ‘Mike McCauley’ :

http://www.airspayce.com/mikem/arduino/AccelStepper/index.html

 

Once downloaded, just extract the content of the zip files inside your “arduino/libraries” folder, and make sure to restart the Arduino IDE (Close and Reopen) software so it detect this newly installed library.