Joystick Control

Joystick Control © GPL3+

A joy stick is used to glow different led

  • 87 views
  • 2 comments
  • 0 respects

Components and supplies

About this project

This project is for arduino beginners. I made this project so that I could understand the basics of a joystick controller and to study it better I made 3x3 led matrix so that as the joystick mo

ves, we can practically see its movement.

Code

joystickC/C++
int x=0,y=0;
void setup()
{
 pinMode(A0,INPUT);
 
 pinMode(A1,INPUT);
 pinMode(0,OUTPUT);
 pinMode(1,OUTPUT);
 pinMode(2,OUTPUT);
 pinMode(3,OUTPUT);
 pinMode(4,OUTPUT);
 pinMode(5,OUTPUT);
 pinMode(6,OUTPUT);
 pinMode(7,OUTPUT);
 pinMode(8,OUTPUT);
}
void loop()
{ 
 x=analogRead(A0);
 y=analogRead(A1);
 if((x>=0 && x<=254)&&(y>=0 && y<=256))
 {
  digitalWrite(0,HIGH);digitalWrite(4,LOW);digitalWrite(1,LOW);digitalWrite(2,LOW);digitalWrite(13,LOW);digitalWrite(5,LOW);digitalWrite(6,LOW);digitalWrite(7,LOW);digitalWrite(8,LOW);
 }
 else
 if((x>254 && x<=765)&&(y>=0 && y<=256))
 {
  digitalWrite(1,HIGH);digitalWrite(0,LOW);digitalWrite(4,LOW);digitalWrite(2,LOW);digitalWrite(13,LOW);digitalWrite(5,LOW);digitalWrite(6,LOW);digitalWrite(7,LOW);digitalWrite(8,LOW);
 }
 else
 if((x>765 && x<=1023)&&(y>=0 && y<=256))
 {
  digitalWrite(2,HIGH);digitalWrite(0,LOW);digitalWrite(4,LOW);digitalWrite(7,LOW);digitalWrite(13,LOW);digitalWrite(5,LOW);digitalWrite(6,LOW);digitalWrite(1,LOW);digitalWrite(8,LOW);
 }
 else
 if((x>=0 && x<=254)&&(y>256 && y<=767))
 {
  digitalWrite(13,HIGH);digitalWrite(0,LOW);digitalWrite(4,LOW);digitalWrite(2,LOW);digitalWrite(1,LOW);digitalWrite(5,LOW);digitalWrite(6,LOW);digitalWrite(7,LOW);digitalWrite(8,LOW);
 }
 else
 if((x>254 && x<=765)&&(y>256 && y<=767))
 {
  digitalWrite(4,HIGH);digitalWrite(0,LOW);digitalWrite(13,LOW);digitalWrite(2,LOW);digitalWrite(5,LOW);digitalWrite(1,LOW);digitalWrite(6,LOW);digitalWrite(7,LOW);digitalWrite(8,LOW);
 }
 else
 if((x>765 && x<=1023)&&(y>256 && y<=767))
 {
  digitalWrite(5,HIGH);digitalWrite(0,LOW);digitalWrite(4,LOW);digitalWrite(1,LOW);digitalWrite(13,LOW);digitalWrite(2,LOW);digitalWrite(6,LOW);digitalWrite(7,LOW);digitalWrite(8,LOW);
 }
 else
 if((x>=0 && x<=254)&&(y>767 && y<=1023))
 {
  digitalWrite(6,HIGH);digitalWrite(0,LOW);digitalWrite(4,LOW);digitalWrite(2,LOW);digitalWrite(13,LOW);digitalWrite(5,LOW);digitalWrite(8,LOW);digitalWrite(7,LOW);digitalWrite(1,LOW);
 }
 else
 if((x>254 && x<=765)&&(y>767 && y<=1023))
 {
  digitalWrite(7,HIGH);digitalWrite(0,LOW);digitalWrite(4,LOW);digitalWrite(2,LOW);digitalWrite(13,LOW);digitalWrite(5,LOW);digitalWrite(8,LOW);digitalWrite(6,LOW);digitalWrite(1,LOW);
 }
 else
 if((x>765 && x<=1023)&&(y>767 && y<=1023))
 {
  digitalWrite(8,HIGH);digitalWrite(0,LOW);digitalWrite(4,LOW);digitalWrite(2,LOW);digitalWrite(13,LOW);digitalWrite(5,LOW);digitalWrite(6,LOW);digitalWrite(7,LOW); digitalWrite(1,LOW);
 }
}

Comments

Similar projects you might like

Control an LED with the Remote Control

Project showcase by Nicholas_N

  • 3,262 views
  • 2 comments
  • 9 respects

Servo Control with TV Remote Control

Project showcase by eldo85

  • 5,697 views
  • 5 comments
  • 18 respects

Arduino Joystick Servo Control Using 1Sheeld

Project tutorial by amrmostaafaa

  • 2,047 views
  • 0 comments
  • 12 respects

Mega Bread - Atari Joystick Linking for Robotics Control

Project in progress by Pigeon-Kicker

  • 1,445 views
  • 3 comments
  • 10 respects
Add projectSign up / Login