Hackster is hosting Hackster Holidays, Ep. 2: Livestream & Giveaway Drawing. Start streaming on Friday!Stream Hackster Holidays, Ep. 2 on Friday!
SURYATEJA
Published © Apache-2.0

Using Joystick Module with Arduino UNO

This project uses a joystick module with an UNO.

BeginnerFull instructions provided1.5 hours1,842
Using Joystick Module with Arduino UNO

Things used in this project

Story

Read more

Schematics

CONNECTIONS

Code

CODE FOR JOYSTICK USED IN REMOTE CONTROLLERS USING LED DISPLAY

Arduino
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);

// UP-DOWN

if(UD < UPMID - MID){

digitalWrite(DWN, HIGH);

}else{

digitalWrite(DWN, LOW);

}

if(UD > UPMID + MID)

{ digitalWrite(UP, HIGH);

}else{

digitalWrite(UP, LOW);

} // LEFT-RIGHT

if(LR < LRMID - MID){

digitalWrite(LEFT, HIGH);

}else{

digitalWrite(LEFT, LOW);

}

if(LR > LRMID + MID){

digitalWrite(RT, HIGH);

}else{

digitalWrite(RT, LOW);

}

delay(400);

}

Credits

SURYATEJA

SURYATEJA

18 projects • 59 followers

Comments