Small Arcade Joystick (product 480)

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
lineber
 
Posts: 2
Joined: Tue Jan 11, 2011 4:15 am

Small Arcade Joystick (product 480)

Post by lineber »

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

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Small Arcade Joystick (product 480)

Post by adafruit_support_rick »

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?

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

Re: Small Arcade Joystick (product 480)

Post by lineber »

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

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

Re: Small Arcade Joystick (product 480)

Post by RufusTheFirefly »

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

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Small Arcade Joystick (product 480)

Post by adafruit_support_bill »

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

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

Re: Small Arcade Joystick (product 480)

Post by RufusTheFirefly »

Thanks -- that worked great!

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Small Arcade Joystick (product 480)

Post by adafruit_support_bill »

You are welcome Rufus
Image

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

Re: Small Arcade Joystick (product 480)

Post by mscholl »

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

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

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Small Arcade Joystick (product 480)

Post by adafruit_support_bill »

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

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

Re: Small Arcade Joystick (product 480)

Post by mscholl »

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

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

Re: Small Arcade Joystick (product 480)

Post by mscholl »

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

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Small Arcade Joystick (product 480)

Post by adafruit_support_bill »

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.

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

Re: Small Arcade Joystick (product 480)

Post by mscholl »

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

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

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Small Arcade Joystick (product 480)

Post by adafruit_support_bill »

Please use

Code: Select all

 tags when submitting code to the forums[/b]

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

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

Re: Small Arcade Joystick (product 480)

Post by mscholl »

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

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”