Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2014
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.84 KB | None | 0 0
  1. // This #include statement was automatically added by the Spark IDE.
  2. #include "stepper.h"
  3.  
  4. // change this to the number of steps on your motor
  5. #define STEPS 513
  6.  
  7. // create an instance of the stepper class, specifying
  8. // the number of steps of the motor and the pins it's
  9. // attached to
  10. //Stepper stepper(STEPS, D3, D2, D1, D0);//slow
  11.  
  12. int QUARTER_ROTATION = 128;
  13. int SPEED = 5;
  14.  
  15. Stepper stepper(STEPS,D0,D1,D2,D3);
  16.  
  17. int toggleCount = 0;
  18.  
  19. void setup()
  20. {
  21.   Spark.function("toggle", toggle);
  22.   Spark.variable("rpm", &SPEED, INT);
  23.   Spark.variable("toggleCount", &toggleCount, INT);
  24.  
  25.   stepper.setSpeed(SPEED);
  26.   pinMode(D7, OUTPUT);
  27.  
  28. }
  29.  
  30.  
  31. int toggle(String args)
  32. {
  33.     digitalWrite(D7, HIGH);
  34.     stepper.step(QUARTER_ROTATION);
  35.     digitalWrite(D7, LOW);
  36.     toggleCount = toggleCount++;
  37.     return 1;
  38. }
  39.  
  40. void loop()
  41. {
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement