Advertisement
DrAungWinHtut

joystick.ino

Jan 15th, 2025
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Servo.h>
  2.  
  3. Servo steering;
  4.  
  5.  
  6. void setup(){
  7.   pinMode(3,INPUT);
  8.   pinMode(A0,INPUT);
  9.   pinMode(A1,INPUT);
  10.   steering.attach(9);
  11.   Serial.begin(9600);
  12.   Serial.write("The Game is Started!");
  13.  
  14. }
  15.  
  16. void loop(){
  17.  int buttonState = digitalRead(3);
  18.  int x = analogRead(A0);
  19.  int y = analogRead(A1);
  20.  if(buttonState==1)
  21.  {
  22.   Serial.println("Button is Pressed");
  23.   buttonState=0;
  24.  }
  25.  Serial.print("x = ");
  26.  Serial.print(x);
  27.  Serial.print(" - y = ");
  28.  Serial.println(y);
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement