Advertisement
gabbyshimoni

readJoyStickXYvals

Feb 3rd, 2019
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. /*
  2.    03.02.2019
  3.    Written by: Gabby Shimoni
  4.    Description:
  5.    This program reads the X value and Y value of a joystick and print it to Serial monitor
  6. */
  7.  
  8. #define potXpin A0
  9. #define potYpin A1
  10. int potXval = 0, potYval = 0;
  11. void setup() {
  12.   Serial.begin(9600);
  13. }
  14.  
  15. void loop() {
  16.   potXval = analogRead(potXpin);
  17.   potYval = analogRead(potYpin);
  18.   Serial.print("X value = ");
  19.   Serial.print(potXval);
  20.   Serial.print("   Y value = ");
  21.   Serial.println(potYval);
  22.   delay(100);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement