Joystick_values_to_Serial.ino 644 B

123456789101112131415161718192021222324
  1. /* Analog input pins for Joystick XY values */
  2. const int JoyStick_X = 0; // pin number for x
  3. const int JoyStick_Y = 1; // pin number for y
  4. /* Joystick sensitivity */
  5. // We define a JoysStick sensitivity to declare that a movement wish
  6. // is communicated from the user.
  7. // We consider only 4 possibilities:
  8. // foward (++) or backwards (--) for each degree of freedom (X and Y)
  9. const int threshold = 64;
  10. void setup() {
  11. // Initialize the Serial Port
  12. Serial.begin(9600); // 9600 bps
  13. }
  14. void loop() {
  15. Serial.print(analogRead(JoyStick_X));
  16. Serial.print("\t");
  17. Serial.print(analogRead(JoyStick_Y));
  18. Serial.print("\n");
  19. }