Arduino Driving a Micro Stepper Motor – Arduining
Arduino Driving a Micro Stepper Motor – Arduining
Arduining
https://arduining.com/2012/04/22/arduino-driving-a-micro-stepper-motor/ 1/9
30.03.2023, 01:06 Arduino Driving a Micro Stepper Motor – Arduining
Small stepper motors are used to control pointer gauges in motor vehicles.
These motors are small and can be driven directly by the Arduino due to low operation
current (15-25mA per coil). They have gearboxes to increase torque and reduce the
mechanical step.
You can find them in Amazon searching for: stepper motor gauge
Advertisements
https://arduining.com/2012/04/22/arduino-driving-a-micro-stepper-motor/ 2/9
30.03.2023, 01:06 Arduino Driving a Micro Stepper Motor – Arduining
https://arduining.com/2012/04/22/arduino-driving-a-micro-stepper-motor/ 3/9
30.03.2023, 01:06 Arduino Driving a Micro Stepper Motor – Arduining
/*------------------------------------------------------
Gauge_Pot01
Arduining.com 10 July 2011
Direct driving of Miniature Stepper Motor used as an indicator
drive for dashboard instrumentation.
Hardware:
-Arduino UNO.
-Potentiometer.
-Stepper Motor VID29-05P (Can be directly driven by MCU):
-Low current consumption: <20mA
-Rotation Angle:Max 315°
-0.5°/full step
-Coil resistance: 280 +/- 20Ω
-----------------------------------------------------*/
#include <Stepper.h>
#define STEPS 720 // steps per revolution (limited to 315°)
#define COIL1 8
#define COIL2 9
#define COIL3 10
#define COIL4 11
#define PotIn 0
void setup(){
stepper.setSpeed(30); // set the motor speed to 30 RPM (360 PPS
aprox.).
stepper.step(630); //Reset Position(630 steps counter-
clockwise).
// Serial.begin(9600); //for debuging.
}
int pos=0; //Position in steps(0-630)= (0°-315°)
void loop(){
int val = analogRead(PotIn); //get the potentiometer value (range
0-1023)
val= map(val,0,1023,0,630); // map pot range in the stepper
range.
https://arduining.com/2012/04/22/arduino-driving-a-micro-stepper-motor/ 4/9
30.03.2023, 01:06 Arduino Driving a Micro Stepper Motor – Arduining
}
// Serial.println(pos); //for debuging...
// Serial.println(val);
// delay(100);
}
Published by ardunaut
Add Comment
Reply
3. bernard says:
November 16, 2012 at 2:14 PM
clamp diodes are included in the chip
Reply
4. Rhon says:
November 24, 2012 at 4:03 PM
I do not understand where it would be the diodes? could explain better?
Reply
1. Marcel says:
September 6, 2014 at 6:07 PM
I’m thinking the same as Flavio and Rhon… shouldn’t there be diodes between the
motor coils and the Arduino to stop the back-emf from frying the Arduino?
Bernard — what chip? The Arduino doesn’t have diodes on the IO pins as far as I
know and I don’t see another chip (like an L293D) in the circuit.
Reply
2. ardunaut says:
https://arduining.com/2012/04/22/arduino-driving-a-micro-stepper-motor/ 5/9
30.03.2023, 01:06 Arduino Driving a Micro Stepper Motor – Arduining
In several experiments the bare motor was used with Arduino UNO, Arduino
NANO and the Trinket from Adafruit (ATMEGA328 and ATTINY85
microcontrollers) with good results, not recommended for a commercial application.
Reply
3. Mikeg says:
August 20, 2015 at 4:43 PM
There are ESD protection diodes on the chip that will withstand the back-emf of the
motor.
Reply
1. Brynn Rogers says:
November 25, 2019 at 11:09 AM
ESD protection diodes are NOT suitable for protecting a circuit from a coil
flyback. You need to use flyback diodes on all coils.
4. Gengis says:
March 22, 2017 at 5:33 PM
I think “protection diodes are on the chip” refers to to the fact that in ATmega328/P
chips “All I/O pins have protection diodes to both VCC and Ground”; this is a
quotation from the Atmel’s ATmega328/P complete datasheet available online at
http://www.atmel.com/Images/Atmel-42735-8-bit-AVR-Microcontroller-ATmega328-
328P_Datasheet.pdf.
Reply
5. guycarpenter says:
November 26, 2012 at 3:34 AM
Your step calculations for number of steps seem to be based on 1/2 degree per step, but
the VID29 data sheet
(http://guy.carpenter.id.au/gaugette/resources/vid/20091026113525_VID29_manual_EN-
080606.pdf) shows 1/3 of a degree per step. Seems to me full-scale should be 945 steps
rather than 630.
Reply
1. Gérald Charbonier says:
August 6, 2015 at 6:21 PM
GuyCarpenter, How to calculate number of steps please ?
Reply
6. Gary Parker says:
December 17, 2012 at 11:55 PM
I need more thorough explanation for these, ah still not absorbing in my mind. But
thanks anyway for the step-by-step video process, it’s make it more easier.
Reply
https://arduining.com/2012/04/22/arduino-driving-a-micro-stepper-motor/ 6/9
p
30.03.2023, 01:06y Arduino Driving a Micro Stepper Motor – Arduining
7. Claudio says:
March 23, 2013 at 5:56 PM
Hi, please potentiometer characteristics?
Reply
1. ardunaut says:
March 23, 2013 at 7:57 PM
I used a linear type of 10 Kohms, but any value from 5K to 100K will work.
Reply
1. Neil says:
December 29, 2015 at 9:05 AM
Hi, I am very new to this… I cannot find much information on the limits of what
can be used as analogue inputs, I have just ordered my fist Arduino UNO, I have
an application that i would like to monitor a resistance between 3.5 and 70 ohms,
do you know if this is possible ?
Many thanks
Reply
9. Pingback: Arduino Uno - Setup and Programming Tutorials - Into Robotics
10. Calin Dragos George says:
June 29, 2013 at 1:32 AM
A wonderful guide to start working with Arduino Uno. As you can see I add a link in
my article http://www.intorobotics.com/arduino-uno-setup-and-programming-
tutorials/ where is an impressive collection of guides and tutorials to start working with
Uno.
Reply
11. Pingback: Hunt for cheap steppers cont’d: VID teardown, datasheets | orange narwhals
12. Pingback: miniature things research (tiny steppers!) / start-lolling, start-trolling, start-
rolling | orange narwhals
13. Matija Zajšek says:
December 7, 2015 at 10:34 AM
Ok, thanks. Don’t understand your answer to one of the comments – clamp diodes are
included in the chip…?? You you clearify this one?
Reply
14. Pingback: The Firebrid Hybrid Convertible Project - Page 4 - Fuel Economy,
Hypermiling, EcoModding News and Forum - EcoModder.com
15. jasim khan says:
March 7, 2016 at 1:28 PM
can i used this code for all types of stepper motor ?
Reply
16. Winner says:
November 17, 2018 at 11:46 AM
how to change input for control stepping motor from POT to Dc 0-5Vdc? Thanks.
Reply
https://arduining.com/2012/04/22/arduino-driving-a-micro-stepper-motor/ 7/9
30.03.2023, 01:06 Arduino Driving a Micro Stepper Motor – Arduining
Reply
18. Pingback: Arduino Driving a Micro Stepper Motor – PRODUK VIRAL 2022
© 2023 ARDUINING
https://arduining.com/2012/04/22/arduino-driving-a-micro-stepper-motor/ 8/9
30.03.2023, 01:06 Arduino Driving a Micro Stepper Motor – Arduining
https://arduining.com/2012/04/22/arduino-driving-a-micro-stepper-motor/ 9/9