kennyho-rass

servotlacitka

Oct 23rd, 2020
2,129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Servo.h>
  2.  
  3. #define SERVO   12
  4. #define VLEVO   16
  5. #define VPRAVO  17
  6.  
  7. #define MIN 0
  8. #define MAX 180
  9.  
  10. Servo mojeServo;
  11.  
  12. void setup()
  13. {
  14.   pinMode(VLEVO, INPUT_PULLUP);
  15.   pinMode(VPRAVO, INPUT_PULLUP);
  16.   mojeServo.attach(SERVO);
  17. }
  18.  
  19. int uhel = 90;
  20.  
  21. void loop()
  22. {
  23.   if (digitalRead(VLEVO) == 0) {
  24.     if (uhel > MIN) uhel--;
  25.   }  
  26.   if (digitalRead(VPRAVO) == 0) {
  27.     if (uhel < MAX) uhel++;
  28.   }  
  29.   mojeServo.write(uhel);
  30.   delay(20);                        
  31. }
Advertisement
Add Comment
Please, Sign In to add comment