Advertisement
B-Matt

Arduino - LCD Joystick

Nov 25th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. //YWROBOT
  2. //Compatible with the Arduino IDE 1.0
  3. //Library version:1.1
  4. #include <Wire.h>
  5. #include <LiquidCrystal_I2C.h>
  6.  
  7. LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display
  8.  
  9. void setup()
  10. {
  11.   lcd.init();                      // initialize the lcd
  12.   lcd.init();
  13.   // Print a message to the LCD.
  14.   lcd.backlight();
  15. }
  16.  
  17.  
  18. void loop()
  19. {
  20.   int rx = analogRead(A0);
  21.   int ry = analogRead(A1);
  22.   int tempX, tempY,
  23.       x = rx, br=0;
  24.  
  25.   if(tempX != rx) {
  26.     lcd.setCursor(0,0);
  27.     lcd.print("x=");
  28.     lcd.print(rx);
  29.     lcd.print("  ");
  30.     tempX = rx;
  31.   }
  32.  
  33.   if(tempY != ry) {
  34.     lcd.setCursor(0,1);
  35.     lcd.print("y=");
  36.     lcd.print(ry);
  37.     lcd.print("  ");
  38.     tempY = ry;
  39.   }
  40.   delay(50);
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement