If you have hard-time 3d printing stuff and other materials which i have provided in this project please refer the professionals for the help, JLCPCB is one of the best company from shenzhen china they provide, PCB manufacturing, PCBA and 3D printing services to people in need, they provide good quality products in all sectors

Please use the following link to register an account in JLCPCB

jlcpcb.com/RNA

Pcb Manufacturing

----------

2 layers

4 layers

6 layers

jlcpcb.com/RNA

PCBA Services

JLCPCB have 350k+ Components In-stock. You don’t have to worry about parts sourcing, this helps you to save time and hassle, also keeps your costs down.

Moreover, you can pre-order parts and hold the inventory at JLCPCB, giving you peace-of-mind that you won't run into any last minute part shortages. jlcpcb.com/RNA

3d printing

-------------------

SLA -- MJF --SLM -- FDM -- & SLS. easy order and fast shipping makes JLCPCB better companion among other manufactures try out JLCPCB 3D Printing servies

JLCPCB 3D Printing starts at $1 &Get $54 Coupons for new users

The Analog Joystick is similar to two potentiometers connected together, one for the vertical movement (Y-axis) and other for the horizontal movement (X-axis). The joystick also comes with a Select switch. It can be very handy for retro gaming, robot control or RC cars. So let's understand how it works!

The home position for the stick is at ( x,y:511,511). If the stick is moved on X axis from one end to the other, the X values will change from 0 to 1023 and similar thing happens when moved along the Y axis. On the same lines you can read position of the stick anywhere in upper half hemisphere from combination of these values.

The potentiometers act as voltage dividers. This module produces an output of around 2.5V from X and Y when it is in the resting position. Moving the joystick will cause the output to vary from 0v to 5V depending on its direction. If you connect this module to a microcontroller, you can expect to read a value of around 512 in its resting position (expect small variations due to tiny imprecisions of the springs and mechanism). When you move the joystick you should see the values change from 0 to 1023 depending on its position. The given example values are for a 5V microcontroller or a development board with 10bit ADC resolution like Arduino UNO or nano

The Joystick itself only contains the two potentiometers for each axis and a switch to register the click. One side of the potentiometers is connected to the ground and the other to the VCC. The center pins are connected to the VRx and VRy pins respectively. Similarly, the switch is connected between the GND and the SW pins. And in some modules, there is also an unpopulated space for a pull-up resistor on board for the switch.

If your Joystick module is not working properly the first and important step is to make sure all the connections are correct. Once the connections are verified, we can move forward to the next diagnosing step. If the reading from the VRx and VRy is not proper or it jumps around too much, then there must be a problem with the potentiometers. You can gently pop the potentiometers out of their default position by lifting them slightly. Give them a good clean using IPA or a similar cleaning solution and then pop them back in, to see if this has fixed the issue. If not either replace the potentiometer or the module itself.

The sketch starts by defining the connections to the Joystick module. The SW pin is connected to Arduino’s Pin A2 while the VRx and VRy pins are connected to Analog pins A0 and A1.

#define Xaxis_pin A0 // Arduino pin connected to the VRx Pin#define Yaxis_pin A1 // Arduino pin connected to the VRy Pin#define SW_pin A2 // Arduino pin connected to the SW Pin

In the setup() function, we initialized the SW pin as an input and keep it HIGH. This is as same as declaring the pin as INPUT_PULLUP. When the switch is pressed, this pin will be pulled to the ground. Thus, we can detect the button press by monitoring the state of this pin. We have also initialized the serial communication so that we can print all the necessary information into the serial monitor.

void setup() {  pinMode(SW_pin, INPUT);  digitalWrite(SW_pin, HIGH);  Serial.begin(9600);}

In loop() function, we continously read the value of SW pin using digitalRead() function, VRx & VRy pin using analogRead() and display on serial monitor.

void loop() {  Serial.print("X-axis: ");  Serial.print(analogRead(Xaxis_pin));  Serial.print(" : ");  Serial.print("Y-axis: ");  Serial.print(analogRead(Yaxis_pin));  Serial.print(" : ");  Serial.print("Switch:  ");  Serial.println(digitalRead(SW_pin));  delay(200);}

Joystick module Interfacing with Arduino

The below GIF shows how we have interfaced the Joystick module with the Arduino. As you can see as soon as I move the joystick, the corresponding values are displayed on the serial monitor.

Applications like video games that require a change in cursor position in a 2-D plane make use of analog joysticks as input devices.

Analog joystick produces two voltages; one corresponding to position with respect to X-axis and another corresponding to the position with respect to Y-axis. The voltages produced depend on the position of the joystick.

For more information about Analog Joystick and how to use it, refer the topic Analog Joystick in the sensors and modules section.

To interface the Analog Joystick with Arduino Uno, we need to use ADC on the microcontroller of the Arduino UNO board.

Applications like video games that require a change in cursor position in a 2-D plane make use of analog joysticks as input devices.

Analog joystick produces two voltages; one corresponding to position with respect to X-axis and another corresponding to the position with respect to Y-axis. The voltages produced depend on the position of the joystick.

For more information about Analog Joystick and how to use it, refer the topic Analog Joystick in the sensors and modules section.

To interface the Analog Joystick with Arduino Uno, we need to use ADC on the microcontroller of the Arduino UNO board.

Connect your Leonardo board to your computer with a micro-USB cable. The pushbutton is connected to pin 6. If you're using a part like the Joystick shield pictured below, you may not need a pulldown resistor. The x-axis on the joystick is connected to analog in 0, the y-axis is on analog in 1.

Those who are familiar with the PS2 (PlayStation 2) controller will notice that this joystick is strikingly similar to the one used in that device. It is a self-centering spring-loaded joystick, which means that when you release it, it will center itself. It also has a comfortable cup-type knob/cap that feels like a thumb-stick.

Potentiometers

The basic idea behind a joystick is to convert the stick’s position on two axes — the X-axis (left to right) and the Y-axis (up and down) — into an electrical signal that a microcontroller can process. This is accomplished by incorporating two 5K potentiometers (one for each axis) connected with a gymbal mechanism that separates “horizontal” and “vertical” movements.

How does the Thumb Joystick Module Work?

It is truly remarkable how a joystick can translate every tiny motion of your fingertips. This is made possible by the joystick’s design, which consists of two potentiometers and a gimbal mechanism.

Gimbal Mechanism

When you move the joystick, a thin rod that sits between two rotatable-slotted-shafts (Gimbal) moves. One of the shafts allows movement along the X-axis (left and right), while the other allows movement along the Y-axis (up and down).

This output voltage can be fed to an ADC on a microcontroller to determine the physical position of the joystick.

Because the Arduino board has a 10-bit ADC resolution, the values on each analog channel (axis) can range from 0 to 1023. Therefore, when the joystick is moved from one extreme to the other, it will read a value between 0 and 1023 for the corresponding channel. When the joystick is centered, the vertical and horizontal channels will both read 512.

int x; // variable holding the value from A0int y; // variable holding the value from A1int b; // variable holding the value from digital pin 2PFont f; // define the font variableString portName;String val;

In the setup function, we first set the window size to 512×512. Next, we use Serial.list()[0] to open the first available serial port. If this does not work, select the port to which Arduino is connected. We also select a font for displaying our values on the window.

is the vertical output voltage. Moving the joystick up and down causes the output voltage to change from 0 to VCC. The joystick will read approximately half of VCC when it is centered (rest position).

SW is the output from the pushbutton switch. By default, the switch output is floating. To read the switch, a pull-up resistor is required so that when the joystick knob is pressed, the switch output becomes LOW, otherwise it remains HIGH. Keep in mind that the input pin to which the switch is connected must have the internal pull-up enabled, or an external pull-up resistor must be connected.

Wiring a Thumb Joystick Module to an Arduino

Now that we know everything about the joystick module, let’s hook it up to the Arduino.

To begin, connect VRx to Arduino’s analog pin A0 and VRy to analog pin A1. To detect whether the joystick is pressed, we connect the joystick’s SW pin to Arduino digital pin D8.

Finally, connect the VCC pin to the 5V terminal and the GND pin to the Arduino’s ground terminal.

Arduino Code

This example sends the state of the pushbutton and two analog outputs serially to the computer. The associated Processing sketch reads the serial data to animate the joystick position.

The sketch is identical to the one above, except that the values printed on the serial monitor are separated by commas. The reason for separating values with commas is to make data transfer easier. The concept here is to send the values as a comma-separated string that we can parse in the Processing IDE to retrieve the values.

Upload the sketch below to your Arduino.

int xValue = 0 ; // read value of the X axis	int yValue = 0 ; // read value of the Y axis	int bValue = 0 ; // value of the button reading	void setup()	{		Serial.begin(9600) ; // Open the serial port	pinMode(8,INPUT) ; // Configure Pin 2 as input	digitalWrite(8,HIGH);	}	void loop()	{		// Read analog port values A0 and A1		xValue = analogRead(A0);		yValue = analogRead(A1);		// Read the logic value on pin 2		bValue = digitalRead(8);		// We display our data separated by a comma		Serial.print(xValue,DEC);	Serial.print(",");	Serial.print(yValue,DEC);	Serial.print(",");	Serial.print(!bValue);	// We end with a newline character to facilitate subsequent analysis		Serial.print("\n");	// Small delay before the next measurement		delay(10);	}

Processing Code

After uploading the program to Arduino, we can begin animating the joystick position in the Processing IDE. Keep your Arduino plugged in and run the Processing code below.

import processing.serial.*; //import the Serial librarySerial myPort;int x; // variable holding the value from A0int y; // variable holding the value from A1int b; // variable holding the value from digital pin 2PFont f; // define the font variableString portName;String val;void setup(){  size ( 512 , 512 ) ; // window size    // we are opening the port   myPort = new Serial(this, Serial.list()[0], 9600);  myPort.bufferUntil('\n');     // choose the font and size  f = createFont("Arial", 16, true); // Arial, 16px, anti-aliasing  textFont ( f, 16 ) ; // size 16px}// drawing loopvoid draw(){  fill(0) ; // set the fill color to black  clear() ; // clean the screen    fill(255) ; // set the fill color to white    if (b == 1) // check if the button is pressed  {    // draw a larger circle with specified coordinates    ellipse(x/2,y/2, 50, 50);  }   else  {    // we draw a circle with a certain coordinates    ellipse(x/2,y/2, 25, 25);  }    // we display data  text("AnalogX="+(1023-x)+" AnalogY="+(1023-y),10,20);}// data support from the serial portvoid serialEvent( Serial myPort) {  // read the data until the newline n appears  val = myPort.readStringUntil('\n');    if (val != null)  {        val = trim(val);            // break up the decimal and new line reading    int[] vals = int(splitTokens(val, ","));        // we assign to variables    x = vals[0];    y = vals[1] ;    b = vals[2];  }}

Code Explanation:

Let’s quickly analyze the code. First, we import the serial library in order to read values from the serial port.

import processing.serial.*; //import the Serial librarySerial myPort;

The variables that will hold the x-axis, y-axis, and button state values are then declared.

fill(0) ; // set the fill color to black  clear() ; // clean the screen    fill(255) ; // set the fill color to white    if (b == 1) // check if the button is pressed  {    // draw a larger circle with specified coordinates    ellipse(x/2,y/2, 50, 50);  }   else  {    // we draw a circle with a certain coordinates    ellipse(x/2,y/2, 25, 25);  }The x- and y-axis values are then printed in the upper left corner of the window.  // we display data  text("AnalogX="+(1023-x)+" AnalogY="+(1023-y),10,20);The custom function serialEvent(Serial myPort) helps us parse a comma-separated list of values.void serialEvent( Serial myPort) {  // read the data until the newline n appears  val = myPort.readStringUntil('\n');    if (val != null)  {        val = trim(val);            // break up the decimal and new line reading    int[] vals = int(splitTokens(val, ","));        // we assign to variables    x = vals[0];    y = vals[1] ;    b = vals[2];  }}

Schematics

Schematics

Circuit

Code

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>

#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10

#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_BME280 bme; // I2C
//Adafruit_BME280 bme(BME_CS); // hardware SPI
//Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI

unsigned long delayTime;

void setup() {    Serial.begin(115200);    while(!Serial);    // time to get serial running    Serial.println(F("BME280 test"));