KEMBAR78
Connect and Use Joystick With Arduino | PDF | Arduino | Electronic Engineering
0% found this document useful (0 votes)
51 views5 pages

Connect and Use Joystick With Arduino

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views5 pages

Connect and Use Joystick With Arduino

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

instructables

Connect and Use Joystick With Arduino

by BlueMatter

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.

https://youtu.be/NzAfZV-GXxA

Step 1: Step 1:You Will Need

Jumper wire
Joystick Module
4 resistor 220hom
Arduino UNO
4 leds

Watch the video tutorial

Connect and Use Joystick With Arduino: Page 1


Step 2: 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

Connect and Use Joystick With Arduino: Page 2


Step 4: Step 4:THE CODE

Connect and Use Joystick With Arduino: Page 3


int UD = 0; pinMode(LEFT, OUTPUT);

int LR = 0; pinMode(RT, OUTPUT);

/* Arduino Micro output pins*/ digitalWrite(DWN, HIGH);

int DWN = 13; digitalWrite(UP, HIGH);

int UP = 12; digitalWrite(LEFT, HIGH);

int LEFT = 11; digitalWrite(RT, HIGH);

int RT = 10; //calabrate center

/*Arduino Micro Input Pins */ LRMID = analogRead(ILR);

int IUP=A0; UPMID = analogRead(IUP); }

int ILR=A1; void loop(){

int MID = 10; // 10 mid point delta arduino, use 4 for UD = analogRead(IUP);
attiny
LR = analogRead(ILR);
int LRMID = 0;
// UP-DOWN
int UPMID = 0;
if(UD < UPMID - MID){
void setup(){
digitalWrite(DWN, HIGH);
pinMode(DWN, OUTPUT);
}else{
pinMode(UP, OUTPUT);

digitalWrite(DWN, LOW);

if(UD > UPMID + MID)

{ digitalWrite(UP, HIGH);

}else{

digitalWrite(UP, LOW);

} // LEFT-RIGHT

if(LR < LRMID - MID){

digitalWrite(LEFT, HIGH);
Connect and Use Joystick With Arduino: Page 4
}else{

digitalWrite(LEFT, LOW);

if(LR > LRMID + MID){

digitalWrite(RT, HIGH);

}else{

digitalWrite(RT, LOW);

delay(400);

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

Connect and Use Joystick With Arduino: Page 5

You might also like