--> Project V - 30. Arduino Interface with Analog Joystick | basic arduino tutorial

Friday, August 18, 2017

Project V - 30. Arduino Interface with Analog Joystick

| Friday, August 18, 2017
Arduino Interface with Analog Joystick


The Arduino UNO is used to read the data values of X and Y axis which are the output data of the joystick whose results are displayed on the LCD.

Hardware Requirement
  • Arduino Uno Board
  • Joystick Dual Axis Module
  • LCD 16x2
  • Power supply +5 Volt
  • Jumper

Joystick Dual Axis Module | Source

Block Diagram


Schematic


Arduino - LCD Wiring



Arduino - Joystick Module Wiring


Source Code/Sketch


#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
int joyX = A0;
int joyY = A1;
int value1 = 0;
int value2 = 0;
int SW = 8;
int led = 0;
void setup() {
pinMode(13, OUTPUT);
pinMode(SW, INPUT);
digitalWrite(SW, HIGH);
lcd.begin(16, 2);
lcd.print("Baca Joystick");
}
void loop() {
value1 = analogRead(joyX);
value2 = analogRead(joyY);
lcd.setCursor(0 ,1);
//X=46 --> 1018
lcd.print("X:");
lcd.print(value1);
//Y=46 --> 1018
lcd.print(" Y:");
lcd.print(value2);
lcd.print(" ");
if(digitalRead(SW)==0){
delay(100);
led=!led;
digitalWrite(13, led);
}
delay(100);
}


How it Works

1. Connect the Arduino with Peripherals needed.
2. Plug in the Power Source on the device.

3. Add some library if needed
4. Compile and upload the script program above to your arduino.
5. LCD will displays X and Y values, while the SW key is use to turn on and off LED 13 Arduino.


Video for Project V - 30. Arduino Interface with Analog Joystick




Required file

Related Posts

No comments:

Post a Comment