Arduino LED Control With Analog Joystick
by RonFrtek in Circuits > Arduino
4203 Views, 1 Favorites, 0 Comments
Arduino LED Control With Analog Joystick
In this tutorial we will learn how to use analog Joystick to control the LED.
Watch a demonstration video.
What You Will Need
- Arduino UNO (or any other Arduino)
- 4XLED
- Joystick
- 4X Resistor 220Ω (or something similar)
- Breadboard
- Jumper wires
- Visuino program: Download Visuino
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
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
- 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
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