Advertisement
gabbyshimoni

joystickExample

Feb 10th, 2019
569
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #define potXPin A0
  2. #define potYPin A1
  3. #define pbPin  3
  4. int pbValue = 0;
  5. int potXVal=0, potYVal=0;
  6.  
  7. void setup ()
  8. {
  9.   pinMode (pbPin  , INPUT);
  10.   Serial.begin (9600);
  11. }
  12. void loop ()
  13. {
  14.   potXVal= analogRead (potXPin );
  15.   potYVal= analogRead (potYPin );
  16.   pbValue = digitalRead (pbPin  );
  17.  
  18.   Serial.print("X = ");
  19.   Serial.println (potXVal);
  20.  
  21.   Serial.print ("Y = ");
  22.   Serial.println (potYVal);
  23.  
  24.   Serial.print("Button is ");
  25.   if (pbValue == HIGH){
  26.     Serial.println ("not pressed");
  27.   }
  28.   else{
  29.     Serial.println ("PRESSED");
  30.   }
  31.   delay (500);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement