Control Pan-Tilt Servo With Analog Joystick and AVR ATmega16

by chelseacln9x9 in Circuits > Microcontrollers

731 Views, 1 Favorites, 0 Comments

Control Pan-Tilt Servo With Analog Joystick and AVR ATmega16

IMG_5665.JPG

Learn how to set up a servo-based pan-tilt stand with an ATmega16 and a simple Joystick Module.
A joystick is one of the easiest ways to control dual servo motor.

Supplies:
In this circuits we will need the following components:

  • ATmega16
  • MG90S Servo
  • Analog Joystick
  • Pan-Tilt Servo

Step 1: Analog Joystick Module

vol_joystick.png
PS2-Joystick-Module-Movement-Analog-Values-on-Arduino.png

Analog Joystick is similar to two potentiometers connected together, one for the vertical movement (Y-axis) and other for the horizontal movement (X-axis). The joystick also comes with a Select switch. It can be very handy for retro gaming, robot control or RC cars.

After Interfacing Joystick Module, we will get the analog output. The output range is fixed for each direction. The below image shows, the value of analog output for X and Y axis based on the movement of Joystick Module in all four directions (+X, -X, +Y, -Y). You will also get some analog value when moving the knob diagonally.


Step 2 : MG90S Servo Motor

MG90S-Wiring-Diagram.png
31390-large.jpg

Now let’s program AVR ATmega16 to generate 50Hz PWM to control Servo Motor in an angle between -90° to +90° rotation using an analog joystick.

Here we are using ADC channel 0 and 1 of ATmega16 to read the external potentiometer knob and according to the ADC value, we are varying both OCR1A and OCR1B register value in between 65 to 300.

Step 3 : Code

Code Writer 1_7_2021 10_57_59 AM.png
Control Pan - Tilt Servo with Analog Joystick and AVR ATmega16

You can edit the code to make the joystick control smoother by reducing the received analog signal threshold by subdivision the 1024.

Wish you a successful implementation of this project.

Downloads