Advertisement
RealHero

Arduino 3.5

Jun 5th, 2021
937
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.26 KB | None | 0 0
  1. #define MOTOR_PIN A0
  2.  
  3. #define PMOS_PIN 3
  4.  
  5. void setup()
  6.  
  7. {
  8.  
  9. pinMode(PMOS_PIN, OUTPUT);
  10.  
  11. pinMode(MOTOR_PIN, INPUT);
  12.  
  13. }
  14.  
  15. int rot = 0;
  16.  
  17. void loop()
  18.  
  19. {
  20.  
  21. int temp = analogRead(MOTOR_PIN);
  22.  
  23. rot = map(temp,20,358,255,0);
  24.  
  25. analogWrite(PMOS_PIN, rot);
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement