Arduino Led Control With Analog Joystick

About the project

In this tutorial we will learn how to use analog Joystick to control the LED. Watch a demonstration video.

Project info

Difficulty: Easy

Platforms: ArduinoVisuino

Estimated time: 1 hour

License: GNU General Public License, version 3 or later (GPL3+)

Items used in this project

Hardware components

Jumper wires (generic) Jumper wires (generic) x 1
Breadboard (generic) Breadboard (generic) x 1
LED (generic) LED (generic) x 4
Arduino UNO Arduino UNO x 1
Analog joystick (Generic) Analog joystick (Generic) x 1

Software apps and online services

Visuino Visuino
Arduino IDE Arduino IDE

Story

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

Watch a demonstration video.

Step 1: What You Will Need

1 / 6

  • Arduino UNO (or any other Arduino)
  • 4XLED
  • Joystick
  • 4X Resistor 220Ω (or something similar)
  • Breadboard
  • Jumper wires
  • Visuino program: Download Visuino

Step 2: The Circuit

  • 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

Step 3:

1 / 2

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 tutorial will not work! If you have not done follow the steps in this tutorial 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

Step 4: In Visuino ADD & Connect Components

1 / 3

  • 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]

Step 5: Generate, Compile, and Upload the Arduino Code

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.

Step 6: 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 tutorial, you can download it here and open it in Visuino: https://www.visuino.eu

Schematics, diagrams and documents

Visuino File

Code

Visuino File

Credits

Photo of Ron

Ron

Arduino Developer

   

Leave your feedback...