ARDUINO WITH JOYSTICK
In this tutorial you will get to know that how you can control LED's with joystick module.
- JOYSTICK MODULE
- ARDUINO
- YELLOW LED's
- BRAEDBOARD
- JUMPER WIRES
Working
Whenever we move joystick module in any direction LED also changes its brightness according to it.
One LED changes its brightness with joystick X-axis and the other with joystick Y-axis.
CONNECTIONS
ARDUINO
GND = -ve of green , red LED and
GND of joystick module
5V = VCC of joystick module
9 = +ve of 1st LED
10 = +ve of 2nd LED
A1 = X-axis of joystick
A0 = Y-axis of joystick
CODE OF THE PROJECT :-
#define LED 9
#define LED1 10
#define KNOB A0
#define KNOB1 A1
void setup() {
pinMode(LED, OUTPUT);
pinMode(LED1, OUTPUT);
}
#define LED1 10
#define KNOB A0
#define KNOB1 A1
void setup() {
pinMode(LED, OUTPUT);
pinMode(LED1, OUTPUT);
}
void loop() {
int knobValue = analogRead(KNOB);
int knobValue1 = analogRead(KNOB1);
int intensity = map(knobValue, 1, 1024, 1, 255);
int intensity1 = map(knobValue1, 1, 1024, 1, 255);
int intensity1 = map(knobValue1, 1, 1024, 1, 255);
analogWrite(LED, intensity);
analogWrite(LED1, intensity1);
}