This tutorial gives you a quick and simple idea how to control a stepper motor via Raspberry Pi and a Python script.

Parts

Connection between motor and shield

  • Red: A-
  • Green: A+
  • Yellow: B-
  • Blue: B+

Red+Green and Yellow+Blue are one phase each, in this case (4-pin bipolar motor) it does not matter if you swap Red with Green or Yellow with Blue.

 

Connection between shield and RPi

  • 5V+ (VCC): Pin 2
  • GND: Pin 6
  • IN1: Pin 12
  • IN2: Pin 16
  • IN3: Pin 18
  • IN4: Pin 22
  • VIN: Pin 4 (not needed; or separate power source)
  • GND (near VIN): Pin 10 (not needed; or separate power source)

For INx, you can of course choose other GPIO ports on your RPi, but you have to fit the script.

Python Script

 

Pictures

raspberry pi with stepper motor and shield 2

raspberry pi with stepper motor and shield 1

 

Important

In general, I highly recommend to only power the shield (especially the motor) when it is needed, not all the time. The motor takes about 0,5A even when idle, and the L293D chip gets quite hot.

So use a switch etc. for the power line, or maybe use another driver chip.

 

 

 

References:

https://www.raspberrypi.org/forums/viewtopic.php?f=49&t=55580

http://www.elektronx.de/tutorials/schrittmotorsteuerung-mit-dem-raspberry-pi/

 

Share This: