Skip to content

Instantly share code, notes, and snippets.

@msgtn
Last active August 29, 2015 14:16
Show Gist options
  • Save msgtn/4b448301c15ab0e39627 to your computer and use it in GitHub Desktop.
Save msgtn/4b448301c15ab0e39627 to your computer and use it in GitHub Desktop.
Etch-a-sketch IEEE (diagonal)
/*
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 stepsPerRevolution = 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(stepsPerRevolution, 11,9,10,8); // <<<<<<<<<<< Note 8 & 11 swapped
Stepper vert(stepsPerRevolution, 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 drawI()
{
// I
for (int i = 0; i < 6; i++) {
vert.step(-stepsPerRevolution);
}
delay(500);
}
void drawE()
{
// E
for (int i = 0; i < 8; i++) {
horiz.step(stepsPerRevolution);
}
for (int i = 0; i < 4; i++) {
horiz.step(-stepsPerRevolution);
}
for (int i = 0; i < 2; i++) {
vert.step(-stepsPerRevolution);
}
for (int i = 0; i < 4; i++) {
horiz.step(stepsPerRevolution);
}
for (int i = 0; i < 4; i++) {
horiz.step(-stepsPerRevolution);
}
for (int i = 0; i < 2; i++) {
vert.step(-stepsPerRevolution);
}
delay(500);
}
void lastE() {
for (int i = 0; i < 4; i++) {
horiz.step(stepsPerRevolution);
}
}
void loop()
{
drawI();
drawE();
drawE();
drawE();
lastE();
delay(5000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment