Site icon Circuit Ideas for You

Arduino and Joystick LED Controller Circuit

This project shows how to control many LEDs using one joystick and Arduino.

The joystick moves in X and Y direction.

Arduino reads this movement and turns ON or OFF the LEDs.

This Arduino and Joystick LED Controller Circuit is simple to build.

Good for beginners and Arduino lovers.

Arduino Coding:

int VRx = A0
int VRy = A1
int SW = 2

int ledUp = 8
int ledDown = 9
int ledLeft = 10
int ledRight = 11
int ledPress = 12

void setup() {
pinMode(ledUp, OUTPUT)
pinMode(ledDown, OUTPUT)
pinMode(ledLeft, OUTPUT)
pinMode(ledRight, OUTPUT)
pinMode(ledPress, OUTPUT)
pinMode(SW, INPUT_PULLUP)
}

void loop() {
int x = analogRead(VRx)
int y = analogRead(VRy)
int swState = digitalRead(SW)

digitalWrite(ledUp, y < 400)
digitalWrite(ledDown, y > 600)
digitalWrite(ledLeft, x < 400)
digitalWrite(ledRight, x > 600)
digitalWrite(ledPress, swState == 0)
}

Coding Explanation:

Circuit Working:

Arduino and Joystick LED Controller Circuit Diagram

Parts List:

ItemQuantity
Resistors 220Ω 1/4 watt5
Arduino UNO1
Joystick Module1
LEDs 5mm any 5
USB Cable1

The joystick has two potentiometers inside.

One for X direction and one for Y direction.

When we move the stick, the voltage changes.

Arduino reads this voltage on A0 and A1 pins.

According to movement, Arduino turns different LEDs ON.

When joystick goes up, one LED glows.

When joystick goes down, other LED glows.

Right and left also glow different LEDs.

Center position means no LED or one LED.

How to Build:

To build a Arduino and Joystick LED Controller Circuit following are the steps we need to follow:

Conclusion:

This project is easy as it teaches how to read joystick values and control LEDs.

It is good for learning analog input.

We can also use this idea for robot control or game projects.

This Arduino and Joystick LED Controller Circuit is simple with low cost and fun.

References:

LED control with joystick

Exit mobile version