<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://w.electrodragon.com/w/index.php?action=history&amp;feed=atom&amp;title=Stepper_Drive_SDK</id>
	<title>Stepper Drive SDK - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://w.electrodragon.com/w/index.php?action=history&amp;feed=atom&amp;title=Stepper_Drive_SDK"/>
	<link rel="alternate" type="text/html" href="https://w.electrodragon.com/w/index.php?title=Stepper_Drive_SDK&amp;action=history"/>
	<updated>2026-06-04T19:37:27Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.37.2</generator>
	<entry>
		<id>https://w.electrodragon.com/w/index.php?title=Stepper_Drive_SDK&amp;diff=31192&amp;oldid=prev</id>
		<title>Chao: Created page with &quot;== Arduino Simple Demo Dode == === Direct digital write - L9110, ULN2003 === ==== Code 1 ==== thumbnail  === Drive Board with DIR, STEP Pin (A...&quot;</title>
		<link rel="alternate" type="text/html" href="https://w.electrodragon.com/w/index.php?title=Stepper_Drive_SDK&amp;diff=31192&amp;oldid=prev"/>
		<updated>2021-05-17T06:45:28Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== Arduino Simple Demo Dode == === Direct digital write - L9110, ULN2003 === ==== Code 1 ==== &lt;a href=&quot;/w/File:Unipolar_stepper_bb.jpg&quot; title=&quot;File:Unipolar stepper bb.jpg&quot;&gt;thumbnail&lt;/a&gt;  === Drive Board with DIR, STEP Pin (A...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Arduino Simple Demo Dode ==&lt;br /&gt;
=== Direct digital write - L9110, ULN2003 ===&lt;br /&gt;
==== Code 1 ====&lt;br /&gt;
[[File:Unipolar stepper bb.jpg|thumbnail]]&lt;br /&gt;
&lt;br /&gt;
=== Drive Board with DIR, STEP Pin (A3967, A4988) ===&lt;br /&gt;
* A3967&lt;br /&gt;
[[File:Easy-Driver Stepper Motor Driver 08.JPG|400px|thumbnail]]&lt;br /&gt;
Once you have everything hooked up correctly, you can upload firmware to the Arduino. The following is some very simple example code to get you up and running. There are numerous examples online, as well as a Stepper library included with the Arduino IDE. Feel free to play around with this code, changing values to see what happens, and feel free to explore other code.&lt;br /&gt;
==== Demo Code 2 ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Arduino&amp;quot;&amp;gt;&lt;br /&gt;
//simple A4988 connection&lt;br /&gt;
//jumper reset and sleep together&lt;br /&gt;
//connect  VDD to Arduino 3.3v or 5v&lt;br /&gt;
//connect  GND to Arduino GND (GND near VDD)&lt;br /&gt;
//connect  1A and 1B to stepper coil 1&lt;br /&gt;
//connect 2A and 2B to stepper coil 2&lt;br /&gt;
//connect VMOT to power source (9v battery + term)&lt;br /&gt;
//connect GRD to power source (9v battery - term)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int stp = 13;  //connect pin 13 to step&lt;br /&gt;
int dir = 12;  // connect pin 12 to dir&lt;br /&gt;
int a = 0;     //  gen counter&lt;br /&gt;
&lt;br /&gt;
void setup() &lt;br /&gt;
{                &lt;br /&gt;
  pinMode(stp, OUTPUT);&lt;br /&gt;
  pinMode(dir, OUTPUT);       &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void loop() &lt;br /&gt;
{&lt;br /&gt;
  if (a &amp;lt;  200)  //sweep 200 step in dir 1&lt;br /&gt;
   {&lt;br /&gt;
    a++;&lt;br /&gt;
    digitalWrite(stp, HIGH);   &lt;br /&gt;
    delay(10);               &lt;br /&gt;
    digitalWrite(stp, LOW);  &lt;br /&gt;
    delay(10);              &lt;br /&gt;
   }&lt;br /&gt;
  else &lt;br /&gt;
   {&lt;br /&gt;
    digitalWrite(dir, HIGH);&lt;br /&gt;
    a++;&lt;br /&gt;
    digitalWrite(stp, HIGH);  &lt;br /&gt;
    delay(10);               &lt;br /&gt;
    digitalWrite(stp, LOW);  &lt;br /&gt;
    delay(10);&lt;br /&gt;
    &lt;br /&gt;
    if (a&amp;gt;400)    //sweep 200 in dir 2&lt;br /&gt;
     {&lt;br /&gt;
      a = 0;&lt;br /&gt;
      digitalWrite(dir, LOW);&lt;br /&gt;
     }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Use accelstepper library ====&lt;br /&gt;
* [[File:AccelStepper-1.39.zip|Library available here.]]&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Arduino&amp;quot;&amp;gt;&lt;br /&gt;
//This is an example of how you would control 1 stepper&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;AccelStepper.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int motorSpeed = 600; //maximum steps per second (about 3rps / at 16 microsteps)&lt;br /&gt;
int motorAccel = 10000; //steps/second/second to accelerate&lt;br /&gt;
&lt;br /&gt;
int motorDirPin = 2; //digital pin 2&lt;br /&gt;
int motorStepPin = 3; //digital pin 3&lt;br /&gt;
&lt;br /&gt;
//set up the accelStepper intance&lt;br /&gt;
//the &amp;quot;1&amp;quot; tells it we are using a driver&lt;br /&gt;
AccelStepper stepper(1, motorStepPin, motorDirPin); &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void setup(){&lt;br /&gt;
 stepper.setMaxSpeed(motorSpeed);&lt;br /&gt;
 stepper.setSpeed(motorSpeed);&lt;br /&gt;
 stepper.setAcceleration(motorAccel);&lt;br /&gt;
 &lt;br /&gt;
 stepper.moveTo(320); //move 32000 steps (should be 10 rev)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop(){&lt;br /&gt;
 &lt;br /&gt;
 //if stepper is at desired location&lt;br /&gt;
 if (stepper.distanceToGo() == 0){&lt;br /&gt;
  //go the other way the same amount of steps&lt;br /&gt;
  //so if current position is 400 steps out, go position -400&lt;br /&gt;
  stepper.moveTo(-stepper.currentPosition()); &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 //these must be called as often as possible to ensure smooth operation&lt;br /&gt;
 //any delay will cause jerky motion&lt;br /&gt;
 stepper.run();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Stepper library ===&lt;br /&gt;
The Arduino programming environment comes with a function library for controlling a stepper motor. &lt;br /&gt;
To use the library, in the Arduino Editor from the top menu bar: Sketch &amp;gt; Import Library &amp;gt; Stepper. &lt;br /&gt;
Copy the example code below into an Arduino program. &lt;br /&gt;
&lt;br /&gt;
Arduino Example Code Notes :&lt;br /&gt;
#The example code assumes that the stepper is being controlled by Arduino pins 8, 9, 10 and 11, but you can use any set of four pins. &lt;br /&gt;
#The &amp;quot;#define STEPS 100&amp;quot; line defines the number of steps per rev. A 3.75 deg motor has 96 steps/rev while a 7.2 deg motor has 48 steps/rev. &lt;br /&gt;
#The &amp;quot;Stepper stepper(STEPS, 8, 9, 10, 11)&amp;quot; line is where you enter the four pins used to control the stepper. &lt;br /&gt;
#The &amp;quot;stepper.setSpeed(x)&amp;quot; command sets the motor speed to x rpm. &lt;br /&gt;
#The &amp;quot;stepper.step(x)&amp;quot; command turns the motor x steps at the speed last set in the stepper.setSpeed() command. The motor turns one direction for postive x and the reverse direction for negative x.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[category: Stepper Drive]]&lt;/div&gt;</summary>
		<author><name>Chao</name></author>
	</entry>
</feed>