Arduino LED Control With Analog Joystick

by RonFrtek in Circuits > Arduino

4203 Views, 1 Favorites, 0 Comments

Arduino LED Control With Analog Joystick

Arduino LED Control With Analog Joystick - Tutorial

In this tutorial we will learn how to use analog Joystick to control the LED.

Watch a demonstration video.

What You Will Need

dual-axis-xy-joystick-module-ps2-for-arduino-and-others-joystick-module-500x500.jpg
VisuinoAdvrtisementM5Stack7.jpg
arduino-uno-rev-3.jpg
LED5MM.png
jumper-wires.jpg
6a40d745-resistor-220-ohm-14-watt.jpg
20131108211302285.jpg
  • Arduino UNO (or any other Arduino)
  • 4XLED
  • Joystick
  • 4X Resistor 220Ω (or something similar)
  • Breadboard
  • Jumper wires
  • Visuino program: Download Visuino

The Circuit

2020-01-23_11-12-59.jpg

  • Connect Arduino pin[5V] to breadboard positive pin [red line]
  • Connect Arduino pin[GND] to breadboard positive pin [blue line]
  • Connect Joystick pin [VRx] to Arduino Analog pin[1]
  • Connect Joystick pin [VRy] to Arduino Analog pin[0]
  • Connect Joystick pin [+5V] to Breadboard positive pin [red line]
  • Connect Joystick pin [GND] to Breadboard negative pin [blue line]
  • Connect each LED negative pin on the breadboard to breadboard negative pin GND[blue line]
  • Connect each resistor to LED positive pin on the breadboard
  • Connect arduino digital pin[2] to the first resistor
  • Connect arduino digital pin[3] to the second resistor
  • Connect arduino digital pin[4] to the third resistor
  • Connect arduino digital pin[5] to the fourth resistor

FL8QFGAK5H5EPPK.LARGE.jpg
FBL8FPKK5H5EPPI.LARGE.jpg

To start programming the Arduino, you will need to have the Arduino IDE installed from here: https://www.arduino.cc/.

Please be aware that there are some critical bugs in Arduino IDE 1.6.6. Make sure that you install 1.6.7 or higher, otherwise this Instructable will not work! If you have not done follow the steps in this Instructable to setup the Arduino IDE to program Arduino UNO! The Visuino: https://www.visuino.eu also needs to be installed. Start Visuino as shown in the first picture Click on the "Tools" button on the Arduino component (Picture 1) in Visuino When the dialog appears, select "Arduino UNO" as shown on Picture 2

In Visuino ADD & Connect Components

2020-01-23_12-41-32.jpg
2020-01-23_12-44-21.jpg
2020-01-23_12-44-04.jpg
  • Add 4X "Compare Analog Value" component
  • Select "CompareValue2" and in the properties window set "Value" to 1
  • Select "CompareValue4" and in the properties window set "Value" to 1
  • Connect Arduino AnalogIn [0] to "CompareValue1" pin [In] and "CompareValue2" pin [In]
  • Connect Arduino AnalogIn [1] to "CompareValue3" pin [In] and "CompareValue4" pin [In]

  • Connect "CompareValue1" pin [Out] to Arduino digital pin[2]

  • Connect "CompareValue2" pin [Out] to Arduino digital pin[3]

  • Connect "CompareValue3" pin [Out] to Arduino digital pin[4]

  • Connect "CompareValue4" pin [Out] to Arduino digital pin[5]

Generate, Compile, and Upload the Arduino Code

2020-10-30_13-20-50.jpg

In Visuino, at the bottom click on the "Build" Tab, make sure the correct port is selected, then click on the "Compile/Build and Upload" button.

Play

If you power the Arduino UNO module, and move the joystick position the LED will flash.

Congratulations! You have completed your project with Visuino. Also attached is the Visuino project, that I created for this Instructable, you can download it here and open it in Visuino: https://www.visuino.eu