Introduction: Connect and Use Joystick With Arduino

Picture of Connect and Use Joystick With Arduino

A joystick is an input device consisting of a stick that pivots on a base and reports its angle or direction to the device it is controlling.

Joysticks are often used whith Arduino to control robots.

Step 1: Step 1:You Will Need

Picture of Step 1:You Will Need
  • Jumper wire
  • Joystick Module
  • 4 resistor 220hom
  • Arduino UNO
  • 4 leds

Watch the video tutorial

Step 2: Step 2: Connect Joystick Module to an Arduino Uno

Picture of Step 2: Connect Joystick Module to an Arduino Uno

Joistic Module----Arduino

wire yellow y--------pin A0

wire brown x--------pin A1

wire wite bt----------pin 8

wire red vcc---------5v

wire black gnd------gnd

Step 3: Step 3: Connect Led to Arduino

Picture of Step 3: Connect Led to Arduino

Step 4: Step 4:THE CODE

int UD = 0;

int LR = 0;

/* Arduino Micro output pins*/

int DWN = 13;

int UP = 12;

int LEFT = 11;

int RT = 10;

/*Arduino Micro Input Pins */

int IUP=A0;

int ILR=A1;

int MID = 10; // 10 mid point delta arduino, use 4 for attiny

int LRMID = 0;

int UPMID = 0;

void setup(){

pinMode(DWN, OUTPUT);

pinMode(UP, OUTPUT);

pinMode(LEFT, OUTPUT);

pinMode(RT, OUTPUT);

digitalWrite(DWN, HIGH);

digitalWrite(UP, HIGH);

digitalWrite(LEFT, HIGH);

digitalWrite(RT, HIGH);

//calabrate center

LRMID = analogRead(ILR);

UPMID = analogRead(IUP); }

void loop(){

UD = analogRead(IUP);

LR = analogRead(ILR);


if(UD < UPMID - MID){

digitalWrite(DWN, HIGH);


digitalWrite(DWN, LOW);


if(UD > UPMID + MID)

{ digitalWrite(UP, HIGH);


digitalWrite(UP, LOW);


if(LR < LRMID - MID){

digitalWrite(LEFT, HIGH);


digitalWrite(LEFT, LOW);


if(LR > LRMID + MID){

digitalWrite(RT, HIGH);


digitalWrite(RT, LOW);





CarterW16 (author)2017-10-20

have you been able to make it work with the joystick button as well?

About This Instructable




More by BlueMatter:Connect and use Joystick with ArduinoArduino Tutorial - Laser security systemArduino Tutorial - Easy secret knock detector
Add instructable to: