SHARE
TWEET

Figuring Out How to Use a Step Motor

jmyean Apr 21st, 2019 (edited) 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. #include <Stepper.h>
  3. const float STEPS_PER_REV = 64;
  4. Stepper steppermotor(STEPS_PER_REV, 8, 10, 9, 11);
  5. const int PotPin = A0;
  6. int PotVal = 0;
  7. int angle = 0;
  8.  
  9. void setup()
  10. {
  11.   pinMode(PotPin, INPUT);
  12.   Serial.begin(9600);
  13. }
  14.  
  15. void loop()
  16. {
  17.   PotVal = analogRead(PotPin);
  18.   Serial.println(PotVal);
  19.   angle = map(PotVal, 0,1023,0,359);
  20.   steppermotor.step(angle*5);
  21. }
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