Advertisement
RealHero

Arduino 3.4

Jun 5th, 2021
886
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. #define MOTOR_PIN 9
  2.  
  3. int pot = A0;// пин потенциометра
  4.  
  5. void setup()
  6.  
  7. {
  8.  
  9. pinMode(MOTOR_PIN, OUTPUT);
  10.  
  11. pinMode(pot, INPUT);
  12.  
  13. Serial.begin(9600);
  14.  
  15. }
  16.  
  17. void loop()
  18.  
  19. {
  20.  
  21. int val = analogRead(pot) / 4;
  22.  
  23. Serial.println(val);
  24.  
  25. analogWrite(MOTOR_PIN, val);
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement