A Price
Published © GPL3+

Joystick Control

Joystick control with Arduino Nano, Due or Uno.

BeginnerShowcase (no instructions)30 minutes1,518
Joystick Control

Things used in this project

Story

Read more

Schematics

joystick_for_hackster_io_4Zz7XS541V.png

Code

JOYSTICK_FOR_HACKSTER.io.ino

C/C++
//roborobot all rights reserved
// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {

  int sensorValuex = analogRead(A0);//for x value
  int sensorValuey = analogRead(A1);//for y value
  int sensorValueb = analogRead(A2);//for button
  if (sensorValueb == LOW){ //if you press the button
    // print out the value you read:
    
    Serial.println(sensorValuex); //show x value
 
  }// print out the value you read:
  
  else{Serial.println(sensorValuey); //if button has not been pressed show y value
  
  }
   delay(1);    // delay in between reads for stability
  }
//end
//check out  
//www.hackster.io/roborobotno0/joystick-control-c0bd5f    
//that is where this sketch came from
  
  

  

Credits

A Price

A Price

3 projects • 5 followers
I am the best Okie from Muskogee programmer. (https://www.youtube.com/watch?v=D5K5l89mpV8) i have been doing electronics for 4 years.

Comments