0

Small Arcade Joystick (product 480)
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Small Arcade Joystick (product 480)

by lineber on Thu Jul 05, 2012 2:01 am

Hi, I am trying to find the datasheet for product 480, the small arcade joystick. https://www.adafruit.com/products/480

I though this product had enough wires to send parallel signals. But after looking at it closer, I realized it have one to few wires to work the way i imagined.

So the product seems to be serial. If I can look at the datasheet I might be able to figure out how to get this to work with the arduino or the parallel load to 8 bit ic chip I bought. Or if there is a tutorial that explains how to connect 5 wire serial cables to an arduino that would be helpful too. But considering I have no clue which pins do what I would like something specific to this device.

Thanks,

-Jerry

lineber
 
Posts: 2
Joined: Tue Jan 11, 2011 4:15 am

Re: Small Arcade Joystick (product 480)

by adafruit_support_rick on Thu Jul 05, 2012 5:50 am

The device simply has 4 microswitches, one for each cardinal direction. Diagonal joystick positions activate two switches. The output leads are the four switches and ground. Sounds like maybe you're thinking of a proportional joystick instead?

adafruit_support_rick
 
Posts: 34599
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Small Arcade Joystick (product 480)

by lineber on Thu Jul 05, 2012 11:45 pm

Yeah, I had somebody at my hackerspace explain the same thing to me. For some reason, I thought for parallel to work I needed a common ground and supply :oops: . Broke out the multimeter and tested each position. Works perfectly.

Thanks for the quick reply.

-Jerry

lineber
 
Posts: 2
Joined: Tue Jan 11, 2011 4:15 am

Re: Small Arcade Joystick (product 480)

by RufusTheFirefly on Fri Jan 25, 2013 1:17 pm

I am trying to use this on a project right now and I feel like I'm missing something. There are five wires coming out of the joystick, I believe that one is ground and the other four are switches (one for each direction). But unless there is a battery inside the joystick, where does the power come from (so the input pin on my arduino will know when the switch has been activated)? It seems like all the wires are outputs so there is no power coming into the joystick that can form the circuit.

Right now when I plug it into the arduino I get no response or, at best, a kind of random response unrelated to which way the joystick is being moved.

Please help!

Thanks,
Jeff
RufusTheFirefly
 
Posts: 2
Joined: Fri Jan 25, 2013 1:04 pm

Re: Small Arcade Joystick (product 480)

by adafruit_support_bill on Fri Jan 25, 2013 1:32 pm

The common pin goes to ground. The other 4 connect to digital pins. If you enable the internal pullup resistors on those pins, they will be pulled up to 5v until the switch is closed.

http://arduino.cc/en/Reference/pinMode

adafruit_support_bill
 
Posts: 61677
Joined: Sat Feb 07, 2009 10:11 am

Re: Small Arcade Joystick (product 480)

by RufusTheFirefly on Sat Jan 26, 2013 10:29 am

Thanks -- that worked great!
RufusTheFirefly
 
Posts: 2
Joined: Fri Jan 25, 2013 1:04 pm

Re: Small Arcade Joystick (product 480)

by adafruit_support_bill on Sat Jan 26, 2013 5:42 pm

You are welcome Rufus
Image

adafruit_support_bill
 
Posts: 61677
Joined: Sat Feb 07, 2009 10:11 am

Re: Small Arcade Joystick (product 480)

by mscholl on Fri Jul 21, 2017 9:35 am

I am having similar issues to one of the previous people who posted. I bought the arcade joystick to use with a motor controller to run two small motors. I initially wrote the code using arduino for 4 button switches, using my breadboard, and then figured that i would translate it to the joystick, since it also runs on 4 micro switches, But I have run into a problem. I used a screw shield so I could first test the button switches using the pin wires, and then screw in the wires to the joystick at the correct pin sites, without disturbing the wires from the button switches to test it. I had to take the "ground" wire from the joystick and run it to 5v to get the joystick to work, but it worked perfectly.
The problem comes when I start wiring the motor controller directly to the arduino. When I move the 5V wire, it still works well, but the minute I remove the pin wires from the button switches going to the arduino, or the ground wire (to hook it directly from the motor controller to the arduino), one of the motors immediately turns on, and the joystick does not work as it should. I did enable the pullup inputs on the pins to the joystick (10,11,12,13), and move the ground wire on the joystick back to ground (it had been on 5V to work), but no success. I am pretty much at my wits end.
My code is the following (before I added the INPUT PULL_UP statement)
Code: Select all | TOGGLE FULL SIZE
int sw1=10;
int sw2=11;
int sw3=12;
int sw4=13;
int state1;
int state2;
int state3;
int state4;
//MOTOR A
int enA = 9;
int in1 = 8;
int in2 = 7;
 // Motor B
 int enB = 3;
int in3 = 5;
int in4 = 4;

void setup() {
 pinMode(sw1,INPUT);
  pinMode(sw2,INPUT);
  pinMode(sw3,INPUT);
pinMode(sw4,INPUT);
  Serial.begin(9600);
  pinMode(enA, OUTPUT);
  pinMode(enB, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);

}

void loop() {
  state1=digitalRead(sw1);
    state2=digitalRead(sw2);
    state3=digitalRead(sw3);
state4=digitalRead(sw4);   

    if(state1==1) //Make a Right turn
    {analogWrite(enB, 150);
    analogWrite(enA, 0);
       digitalWrite(in3, HIGH);
       digitalWrite(in4, LOW);
         digitalWrite(in1, LOW);
  digitalWrite(in2, LOW);
    }

    else if(state2==1) //Forward Movement
    {analogWrite(enA, 250);
    analogWrite(enB, 250);
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  digitalWrite(in3, HIGH);
  digitalWrite(in4, LOW);
    }
else if(state3==1) //Take a left turn
{analogWrite(enA, 150);
analogWrite(enB,0
);
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  digitalWrite(in3, LOW);
       digitalWrite(in4, LOW);
}
else if(state4==1) //Backward Movement
    {analogWrite(enA, 150);
    analogWrite(enB, 150);
  digitalWrite(in1, LOW);
  digitalWrite(in2, HIGH);
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH);
    }

else
{
    analogWrite(enA, 0);
 analogWrite(enB, 0 );
  digitalWrite(in1, LOW);
  digitalWrite(in2, LOW);
  digitalWrite(in3, LOW);
  digitalWrite(in4, LOW);
}
}
Last edited by adafruit_support_bill on Fri Jul 21, 2017 9:51 am, edited 1 time in total.
Reason: Please use [code] tags when submitting code to the forums

mscholl
 
Posts: 11
Joined: Tue May 30, 2017 12:58 pm

Re: Small Arcade Joystick (product 480)

by adafruit_support_bill on Fri Jul 21, 2017 9:52 am

Please post a photo or diagram of how you have the joystick connected.

adafruit_support_bill
 
Posts: 61677
Joined: Sat Feb 07, 2009 10:11 am

Re: Small Arcade Joystick (product 480)

by mscholl on Fri Jul 21, 2017 10:11 am

I would love to insert if picture if you will tell me how.....

mscholl
 
Posts: 11
Joined: Tue May 30, 2017 12:58 pm

Re: Small Arcade Joystick (product 480)

by mscholl on Fri Jul 21, 2017 10:13 am

joystick issues.JPG
Here is the joystick connected without the breadboard configuration....
joystick issues.JPG (137.35 KiB) Viewed 53 times

mscholl
 
Posts: 11
Joined: Tue May 30, 2017 12:58 pm

Re: Small Arcade Joystick (product 480)

by adafruit_support_bill on Fri Jul 21, 2017 10:37 am

There are two ways to wire a switch. You can wire it to connect to HIGH and use a pulldown resistor. Or you can wire it to connect LOW and use a pullup resistor. Since the Arduino has built-in pullup resistors, that is the simplest way to go.

To use switches that connect LOW with pullups, you need to change two things in your code: set the pinMode to INPUT_PULLUP. And change your switch logic to test for LOW instead of HIGH for a switch closure.

adafruit_support_bill
 
Posts: 61677
Joined: Sat Feb 07, 2009 10:11 am

Re: Small Arcade Joystick (product 480)

by mscholl on Fri Jul 21, 2017 12:26 pm

Thanks for the explanation- so I tried to modify the code. Both motors run at "rest" state, when they should be doing nothing. I changed the state to "0" but also tried "LOW"- the motors still run. They do mostly respond when I use the joystick, with one motor running appropriately. The code is below- what do I need to change so the motors will be still at rest?
Code: Select all | TOGGLE FULL SIZE
int sw1=10;
int sw2=11;
int sw3=12;

int sw4=13;
int state1;
int state2;
int state3;
int state4;
//MOTOR A
int enA = 9;
int in1 = 8;
int in2 = 7;
 // Motor B
 int enB = 3;
int in3 = 5;
int in4 = 4;

void setup() {
 pinMode(sw1,INPUT_PULLUP);
  pinMode(sw2,INPUT_PULLUP);
  pinMode(sw3,INPUT_PULLUP);
pinMode(sw4,INPUT_PULLUP
);
  Serial.begin(9600);
  pinMode(enA, OUTPUT);
  pinMode(enB, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);

}

void loop() {
  state1=digitalRead(sw1);
    state2=digitalRead(sw2);
    state3=digitalRead(sw3);
state4=digitalRead(sw4);   

    if(state1==0) //Make a Right turn
    {analogWrite(enB, 250);
   analogWrite(enA, 0);
       digitalWrite(in3, HIGH);
       digitalWrite(in4, LOW);
         digitalWrite(in1, LOW);
  digitalWrite(in2, LOW);
    }

    else if(state2==0) //Forward Movement
    {analogWrite(enA, 250);
    analogWrite(enB, 250);
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  digitalWrite(in3, HIGH);
  digitalWrite(in4, LOW);
    }
else if(state3==0) //Take a left turn
{analogWrite(enA, 250);
analogWrite(enB,0);
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  digitalWrite(in3, LOW);
       digitalWrite(in4, LOW);
}
else if(state4==0) //Backward Movement
    {analogWrite(enA, 250);
    analogWrite(enB, 250);
  digitalWrite(in1, LOW);
  digitalWrite(in2, HIGH);
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH);
    }

else
{
    analogWrite(enA,0 );
 analogWrite(enB, 0);
  digitalWrite(in1, LOW);
  digitalWrite(in2, LOW);
  digitalWrite(in3, LOW);
  digitalWrite(in4, LOW);
}
}
Last edited by adafruit_support_bill on Fri Jul 21, 2017 12:28 pm, edited 1 time in total.
Reason: Please use [code] tags when submitting code to the forums

mscholl
 
Posts: 11
Joined: Tue May 30, 2017 12:58 pm

Re: Small Arcade Joystick (product 480)

by adafruit_support_bill on Fri Jul 21, 2017 12:33 pm

Please use [code] tags when submitting code to the forums

I'd start by adding some serial output to print the actual button states so you know if it is wired correctly.

adafruit_support_bill
 
Posts: 61677
Joined: Sat Feb 07, 2009 10:11 am

Re: Small Arcade Joystick (product 480)

by mscholl on Fri Jul 21, 2017 12:37 pm

I'm sorry, I do not understand. I am fairly new to this coding thing.....All of my wires are wired correctly- I just need it to not run unless I am pressing the joystick

mscholl
 
Posts: 11
Joined: Tue May 30, 2017 12:58 pm

Please be positive and constructive with your questions and comments.