Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This #include statement was automatically added by the Spark IDE.
- #include "stepper.h"
- // change this to the number of steps on your motor
- #define STEPS 513
- // create an instance of the stepper class, specifying
- // the number of steps of the motor and the pins it's
- // attached to
- //Stepper stepper(STEPS, D3, D2, D1, D0);//slow
- int QUARTER_ROTATION = 128;
- int SPEED = 5;
- Stepper stepper(STEPS,D0,D1,D2,D3);
- int toggleCount = 0;
- void setup()
- {
- Spark.function("toggle", toggle);
- Spark.variable("rpm", &SPEED, INT);
- Spark.variable("toggleCount", &toggleCount, INT);
- stepper.setSpeed(SPEED);
- pinMode(D7, OUTPUT);
- }
- int toggle(String args)
- {
- digitalWrite(D7, HIGH);
- stepper.step(QUARTER_ROTATION);
- digitalWrite(D7, LOW);
- toggleCount = toggleCount++;
- return 1;
- }
- void loop()
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement