0

Analog 2-axis Thumb Joystick with Select Button + Breakout B
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Analog 2-axis Thumb Joystick with Select Button + Breakout B

by KHS on Thu Apr 11, 2019 1:30 pm

I recently purchased an Analog 2-axis Thumb Joystick with Select Button + Breakout Board. This is being coupled with a remote control transmitter and Arduino Nano. The wiring instructions for the circuit state that the +5v Joystick pin is connected to the Nano +5V VCC pin. I am assuming that the VCC pin on the Joystick is the +5v? Many thanks!
Attachments
512-04.jpg
512-04.jpg (317.37 KiB) Viewed 46 times

KHS
 
Posts: 3
Joined: Thu Apr 11, 2019 1:21 pm

Re: Analog 2-axis Thumb Joystick with Select Button + Breako

by adafruit_support_carter on Thu Apr 11, 2019 1:42 pm

Yep. That's correct. It's a fairly simple device. Each axes is just a voltage divider. That means the Xout and Yout values will range from near 0 to near Vcc over their range of motions. So in general you can use whatever you want for Vcc to change the resulting output. However, most often, Vcc is just matched to whatever the voltage level of the board you are using is.

If you are using a 3.3V board, connect Vcc to 3.3V
If you are using a 5V board, connect Vcc to 5V

Here's an example project that shows the joystick wired up:
https://learn.adafruit.com/pro-trinket- ... tick-mouse

adafruit_support_carter
 
Posts: 10368
Joined: Tue Nov 29, 2016 2:45 pm

Re: Analog 2-axis Thumb Joystick with Select Button + Breako

by KHS on Fri Apr 12, 2019 8:41 am

Many thanks....wonderful support!

KHS
 
Posts: 3
Joined: Thu Apr 11, 2019 1:21 pm

Re: Analog 2-axis Thumb Joystick with Select Button + Breako

by KHS on Mon Apr 15, 2019 7:18 am

I am now starting to write my code for the Arduino Nano. This will be a simple remote control throttle using an RF transmitter, my 2 axis Thumb Joystick and the Arduino Nano.

This is the code that was recommended in the instructions:

Code: Select all | TOGGLE FULL SIZE
#include <VirtualWire.h>
#define X_AXIS A0
#define Y_AXIS A1
#define Y_INIT 520
#define TX_PIN 3
int inputSwitch;
int xAxis;
int yAxis;
int switchOn;
void setup()
{   
inputSwitch = 2;
Serial.begin(9600);
pinMode(inputSwitch , INPUT_PULLUP);
vw_set_tx_pin(TX_PIN); // Sets pin D12 as the TX pin
vw_setup(4000); // Bits per sec
}D
void loop()
{
yAxis = analogRead(Y_AXIS);
if(digitalRead(inputSwitch)== LOW)
{
switchOn = 1;
}
else switchOn = 0;
String joystick_data = String(yAxis) + String(",") + String(switchOn);
Serial.println("yAxis = " + String(yAxis - Y_INIT));
Serial.println("Switch state = " + String(switchOn));
Serial.println(String(joystick_data));
String stringData = String(joystick_data);
sendData(stringData);

As a complete new beginner, I am unsure what part of the code using Arduino IDE goes in the "Void Setup" and which goes in the "Void Loop"?
Apologies for my beginner questions, but I intend to learn this technology!
Key
Last edited by adafruit_support_carter on Mon Apr 15, 2019 12:55 pm, edited 1 time in total.
Reason: added [code] tags

KHS
 
Posts: 3
Joined: Thu Apr 11, 2019 1:21 pm

Re: Analog 2-axis Thumb Joystick with Select Button + Breako

by adafruit_support_carter on Mon Apr 15, 2019 12:57 pm

All Arduino sketches require that you have the two functions setup() and loop(). So the most basic sketch that would compile would look like:
Code: Select all | TOGGLE FULL SIZE
void setup() {
}
void loop() {
}

The code in setup() is run once. The code in loop() is run over and over again forever.

adafruit_support_carter
 
Posts: 10368
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.