Advertisement
bigboy00

tester-servo

Oct 12th, 2020
439
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <Wire.h>
  2. #include <LiquidCrystal_I2C.h>
  3.  
  4. LiquidCrystal_I2C lcd(0x27, 16, 2);
  5.  
  6. #include <Servo.h>
  7. Servo myservo;
  8. int potpin = A0;
  9. int val;
  10. int angle;
  11.  
  12.  
  13. void setup() {
  14.  
  15. lcd.begin();
  16. myservo.attach(9);
  17. lcd.clear();
  18. lcd.setCursor(0, 0);
  19. lcd.print("Tester Servo");
  20. delay(2000);
  21. }
  22.  
  23. void loop() {
  24.  
  25. val = analogRead(potpin);
  26. angle = map(val, 0, 1023, 0, 180);
  27. myservo.write(angle);
  28. delay(5);
  29.  
  30. lcd.clear();
  31. lcd.setCursor(0, 0);
  32. lcd.print("Val Pot:");
  33.  
  34. lcd.setCursor(11, 0);
  35. lcd.print(val);
  36.  
  37. lcd.setCursor(0, 1);
  38.  
  39. lcd.print("Unghi :");
  40. lcd.setCursor(11, 1);
  41. lcd.print(angle);
  42.  
  43.  
  44. delay(5);
  45.  
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement