SHARE
TWEET

Adding a Potentiometer to the Continuous Motor Circuit

jmyean Apr 25th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  /*
  2.   *  Jung Min Yean
  3.   *  Learning How to Use a Continuous Motor
  4.   *  04/23/2019
  5.   */
  6.  
  7. const int motorPin = 9;
  8. const int PotPin = A0;
  9. int PotVal = 0;
  10.  
  11.  
  12. void setup()
  13. {
  14.   pinMode(motorPin, OUTPUT);
  15.   pinMode(PotPin, INPUT);
  16.   Serial.begin(9600);
  17. }
  18.  
  19. void loop()
  20. {
  21.   PotVal = analogRead(PotPin);
  22.   int MapVal = map(PotVal,0,1023,0,255);
  23.   analogWrite(motorPin, PotVal);
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top