Joystick Led Pwm

Introduction: Joystick Led Pwm

About: I love to learn,build and design.....

Controlling led or simply reading values of analog values from joystick... let's get started

Step 1: Parts Used

* Arduino uno (with USB cable)
* Joystick (potentiometer)
* led (any)
* Jumper wires(single strand wires)

Step 2: Connection

Easy to understand with this pic I guess and any questions feel free to comment....

x axis to A1

y axis to A0

SW to pin2

+5v to 5v pin or 3.3v pin

and gnd

Led to 11 pin

Step 3: Code

int xPin = A1;
int yPin = A0;

int buttonPin = 2;

int led=11;

int xPosition = 0;

int yPosition = 0;

int buttonState = 0;

void setup()



pinMode(xPin, INPUT);

pinMode(yPin, INPUT);


pinMode(buttonPin, INPUT_PULLUP);


void loop()


xPosition = analogRead(xPin);

yPosition = analogRead(yPin);

buttonState = digitalRead(buttonPin);

Serial.print("X: ");


Serial.print(" | Y: ");


Serial.print(" | Button: ");





Step 4: Testing

You can add another led to to y axis and make to use

Step 5: Potentiometer

Potentiometer can be used instead of joystick

Be the First to Share


    • Pocket-Sized Speed Challenge

      Pocket-Sized Speed Challenge
    • Super-Size Speed Challenge

      Super-Size Speed Challenge
    • Audio Challenge 2020

      Audio Challenge 2020