Jack J. Beale

Jack J. BealeJack J. BealeJack J. Beale
Root
C.V.
Projects
  • C++ / Arduino
  • Python/Micro-Python
  • Robots/Drones
  • Photography Portfolio
Server Login

Jack J. Beale

Jack J. BealeJack J. BealeJack J. Beale
Root
C.V.
Projects
  • C++ / Arduino
  • Python/Micro-Python
  • Robots/Drones
  • Photography Portfolio
Server Login
More
  • Root
  • C.V.
  • Projects
    • C++ / Arduino
    • Python/Micro-Python
    • Robots/Drones
    • Photography Portfolio
  • Server Login
  • Sign In
  • Create Account

  • My Account
  • Signed in as:

  • filler@godaddy.com


  • My Account
  • Sign out


Signed in as:

filler@godaddy.com

  • Root
  • C.V.
  • Projects
    • C++ / Arduino
    • Python/Micro-Python
    • Robots/Drones
    • Photography Portfolio
  • Server Login

Account


  • My Account
  • Sign out


  • Sign In
  • My Account

C++ controller positioning

Using an I2C LED screen + Raspberry Pi PICO  to test controller/joystick positioning.

Designed to give 2 forms of digital output (Direct Axis positioning as well as a generalised set of directions) and direct serial monitoring.


Simplified - Uses a screen and a microcontroller to output the positions of joysticks in a variety of ways.


Download below contains the code and the libraries used.

Downloads

Controller Positioning (zip)Download
Schematic (pdf)Download

Code/Build

Download contains the Code + Libraries used / copy the below code and use it in the Arduino IDE

//19th June 2022

//Created By Jack J. Beale "404" 

//www.Jackbeale.com 

//Designed for testing Joysticks.

//To be used with an I2C LED display - Please see my website for any further information.   

#include <LiquidCrystal_I2C.h> 

LiquidCrystal_I2C lcd(0x3F, 16, 2);  


const int xpin = 28; 

const int ypin = 27; 

const int zpin = 26;  


int ystate; 

int xstate; 

int zstate;  


void setup(){ 

pinMode(ypin, INPUT); 

pinMode(xpin, INPUT); 

pinMode(zpin, INPUT);  


lcd.init();           // LCD driver initialization 

lcd.backlight();      // Open the backlight 

lcd.setCursor(0,0);   // Move the cursor to row 0, column 0 

Serial.begin(9600);   //Start Serial 

}  


void loop (){

ystate = analogRead(ypin); //Get Y State 

xstate = analogRead(xpin); //Get X State 

zstate = analogRead(zpin); //Get Z State 

Serial.println("X,Y,Z: " + String(xstate) + ", " + String(ystate) + ", " + String(zstate)); 

//Outputs to Serial monitor

delay(10); 


//Displays the Raw values of the Joystick Postion - X

   lcd.setCursor(0,0); // Move the cursor to row 0, column 0

   lcd.print("X:");    // Print The X Label

   lcd.print(xstate);  // Print The X State Value

   lcd.print(" ");    // Added to Clean up after a Max digit is shown

   delay(10);  


//Displays the Raw values of the Joystick Postion - Y

   lcd.setCursor(6,0); // Move the cursor to row 1, column 0

   lcd.print("Y:");    // Print The Y Label

   lcd.print(ystate);  // Print The Y State Value

   lcd.print(" ");    // Added to Clean up after a Max digit is shown   delay(10);


 //Displays the Raw values of the Joystick Postion - Z

   lcd.setCursor(12,0); // Move the cursor to row 0, column 12

   lcd.print("Z:");     // Print The Z Label

   lcd.print(zstate);   // Print The Y State Value

   lcd.print(" ");    // Added to Clean up after a Max digit is shown

   delay(10);   


//Displays the Postion of the Joystick - UP/DOWN

   {if (xstate>540) {

     lcd.setCursor(0,1); // Move the cursor to row 1, column 0

     lcd.print("Up  ");  // Print The X State Position

     delay(100);

    }

    else if(xstate<500) {

     lcd.setCursor(0,1); // Move the cursor to row 1, column 0

     lcd.print("Down");  // Print The X State Position

     delay(100);

    }

      else if(xstate=515){

     lcd.setCursor(0,1); // Move the cursor to row 1, column 0

     lcd.print("Null");  // Print The X State Position

     delay(100);

     } 

    }



 //Displays the Postion of the Joystick - LEFT/RIGHT

   {if (ystate>540) {

     lcd.setCursor(6,1); // Move the cursor to row 1, column 0

     lcd.print("Right");   // Print The X State Position

     delay(100);

    }

     else if(ystate<500) {

     lcd.setCursor(6,1); // Move the cursor to row 1, column 0

     lcd.print("Left ");   // Print The X State Position

     delay(100);

    }

      else if(ystate=515) {

     lcd.setCursor(6,1); // Move the cursor to row 1, column 0

     lcd.print("Null ");   // Print The X State Position

     delay(100);

     }

     }


 //Displays the Postion of the Joystick - Push

   {if (zstate<1000)

   {

   lcd.setCursor(12,1); // Move the cursor to row 1, column 12

   lcd.print("Null");   // Print The Z State Position

   delay(10);

   }

   else

   {

   lcd.setCursor(12,1); // Move the cursor to row 1, column 12

   lcd.print("Push");   // Print The Z State Value

   delay(10);

   }

 }

}

Copyright © 2025 Jack Jeremy Beale - All Rights Reserved.

  • Root
  • Contact Me
  • C.V.
  • Photography Portfolio

Powered by

This website uses cookies.

We use cookies to analyze website traffic and optimize your website experience. By accepting our use of cookies, your data will be aggregated with all other user data.

DeclineAccept