Skip to content

Instantly share code, notes, and snippets.

@msgtn
Created March 12, 2015 21:22
Show Gist options
  • Save msgtn/9c41163290fde3af6b0c to your computer and use it in GitHub Desktop.
Save msgtn/9c41163290fde3af6b0c to your computer and use it in GitHub Desktop.
Etch-a-sketch IEEE (Inline)
/*
Stepper Motor Control - one revolution <<<<<<<<<<<<<<<<<<<<< Modified
This program drives a unipolar or bipolar stepper motor.
The motor is attached to digital pins 8 - 11 of the Arduino.
The motor should revolve one revolution in one direction, then
one revolution in the other direction.
Created 11 Mar. 2007
Modified 30 Nov. 2009
by Tom Igoe
*/
#include <Stepper.h>
const int steps = 200; // change this to fit the number of steps per revolution
//const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on pins 8 through 11:
// Stepper myStepper(stepsPerRevolution, 8,9,10,11);
Stepper horiz(steps, 11,9,10,8); // <<<<<<<<<<< Note 8 & 11 swapped
Stepper vert(steps, 7, 5, 6, 4);
void setup()
{
horiz.setSpeed(150);
vert.setSpeed(150);
// set the speed at 60 rpm:
// myStepper.setSpeed(120); //<<<<<<<<<<<<<<< This was 60
// initialize the serial port:
Serial.begin(9600);
}
void loop()
{
//I
for (int i = 0; i < 6; i++) {
vert.step(-steps);
}
// E
for (int i = 0; i < 6; i++) {
horiz.step(steps);
}
for (int i = 0; i < 3; i++) {
horiz.step(-steps);
}
for (int i = 0; i < 3; i++) {
vert.step(steps);
}
for (int i = 0; i < 3; i++) {
horiz.step(steps);
}
for (int i = 0; i < 3; i++) {
horiz.step(-steps);
}
for (int i = 0; i < 3; i++) {
vert.step(steps);
}
// E
for (int i = 0; i < 6; i++) {
horiz.step(steps);
}
for (int i = 0; i < 3; i++) {
horiz.step(-steps);
}
for (int i = 0; i < 3; i++) {
vert.step(-steps);
}
for (int i = 0; i < 3; i++) {
horiz.step(steps);
}
for (int i = 0; i < 3; i++) {
horiz.step(-steps);
}
for (int i = 0; i < 3; i++) {
vert.step(-steps);
}
// E
for (int i = 0; i < 6; i++) {
horiz.step(steps);
}
for (int i = 0; i < 3; i++) {
horiz.step(-steps);
}
for (int i = 0; i < 3; i++) {
vert.step(steps);
}
for (int i = 0; i < 3; i++) {
horiz.step(steps);
}
for (int i = 0; i < 3; i++) {
horiz.step(-steps);
}
for (int i = 0; i < 3; i++) {
vert.step(steps);
}
for (int i = 0; i < 3; i++) {
horiz.step(steps);
}
delay(5000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment