Hi All,
This is as simple project for beginners who wants to test out a JoyStick Module and What it can do. This project is the most simple way to represent the functions of the joystick Module. The Module has 2 potentiometers named X and Y. The only Thing I have done in the programming is to light up each led according to the X and Y values of the joystick Module.
For Example The maximum value each potentiometer can take is 1023, So in the code below the Arduino reads the X pin value and if it is maximum(1023) meaning the X axis of the Joystick is Pushed all the way upward the UP LED is Turned on.
if(analogRead(X_pin) == 1023){
digitalWrite(UP_LED, HIGH);
}
This applies to all other LEDS as well. The maximum and the lowest values are read and according to the values the respective UP, DOWN, RIGHT, LEFT led's are turned on or off.
In the joystick module there is also a switch.This is a very nice feature. It allows the Led's to do something while the switch is read HIGH.
else if(digitalRead(SW_pin) == 0){
digitalWrite(UP_LED, HIGH);
digitalWrite(LEFT_LED, HIGH);
digitalWrite(RIGHT_LED, HIGH);
digitalWrite(DOWN_LED, HIGH);
}.
Thats it for this project. I think it may be able to be used as a simple game or a direction viewing system.
See This Video To See It In Action
https://drive.google.com/file/d/1CexSRCtrmQ_Gmur7kaREi4G0fDZDdJRa/view?usp=sharing
Thanks,
Sanithu
Comments