Created
January 15, 2016 11:06
-
-
Save jnsdbr/d34b933628e8e4721ce0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Bounce.pde | |
// -*- mode: C++ -*- | |
// | |
// Make a single stepper bounce from one limit to another | |
// | |
// Copyright (C) 2012 Mike McCauley | |
// $Id: Random.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $ | |
#include <AccelStepper.h> | |
AccelStepper stepper(1, 9, 8); | |
int pos = 200; | |
#define MS1 6 | |
#define MS2 7 | |
void setup() | |
{ | |
stepper.setMaxSpeed(3000); | |
stepper.setAcceleration(1000); | |
pinMode(MS1, OUTPUT); | |
pinMode(MS2, OUTPUT); | |
// 200 = 1 turn | |
//digitalWrite(MS1, HIGH); | |
//digitalWrite(MS2, LOW); | |
// 200 = 2 turns | |
digitalWrite(MS1, LOW); | |
digitalWrite(MS2, LOW); | |
// 200 = 1/2 turn | |
//digitalWrite(MS1, LOW); | |
//digitalWrite(MS2, HIGH); | |
// 200 / 1/4 turn | |
//digitalWrite(MS1, HIGH); | |
//digitalWrite(MS2, HIGH); | |
} | |
void loop() | |
{ | |
if (stepper.distanceToGo() == 0) | |
{ | |
delay(500); | |
pos = -pos; | |
stepper.moveTo(pos); | |
} | |
stepper.run(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment