Adding a second Stepper motor on MegaPi, not working


i am working in mBlock 3.4.6 i just got my second makeblock stepper, and a new megaPi
because i sam trying to eliminate the problem of having un matched stepper motors…

i have tested all options, the bug occurs when the second motor is called to spin, bascially
the megaPi hangs up. and the second motor, in this case, the one on port 2 will continue to work
as requested by the sketch, but the motor in port 3 stalls.

Is this a power supply issue? what am i doing wrong?


My experience is that stalling is usually related to insufficient power.


got them both spinning using arduino code, mBlock is good, but not the right tool for what i want to do

no i just need to fgure out what the 4 pins are that fire the stepper motors!


Have you looked at the schematic? (link)


yeah! i see that the Dir and the Step pins are all

port 1 D12, D11
port 2 D7, D8
port 3 D9, D6
port 4 D5, D4
but what do i assign for the other 2 wires?



The FAQ at the bottom said:

8.2 Why the Port1 – Port4 of MegaPi are anti-reverse?

A: The Port1 – Port4 of MegaPi are designed as one the row of female header or male header, and they are divided into red or yellow color, which can avoid connecting reversely. The red port is for the input/output of large current, while the yellow port is for I/O pin. The master chip or the driver module may get burn if you connect them reversely.

Here is a link for 4-wire stepper motor wiring from the RepRap wiki too.

@tec_support may also be able to provide some help. :slight_smile:


thanks chuck, still not having any luck.
i was hoping i could just firgure out what 4 pins sent the A+, A-, B+, B- from the digital pins,
but I guess there is a lot more too it then that.

this sketch makes the motor lock up and hum, but no spinning,
im probably going to blow something if i keep experimenting this way.

Stepper Motor Control - one revolution

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
// for your motor

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 33, 31, 12, 11);

void setup() {
// set the speed at 60 rpm:
// initialize the serial port:

void loop() {
// step one revolution in one direction:

// step one revolution in the other direction:


Well, rats. I guess it’s time to call @tec_support. :slight_smile:



For the deep working principle on the megapi and stepper motor to achieve personal DIY project, sorry that we may don’t have enough ability to explain or provide whole support though we want to help.
While here is a example program provided by our engineer to you for reference, hope it helps:


Hello! I have a problem with uploading to arduino… Please help!!! This is what happens when I try to upload my program to my mbot:

My mbot is starts running immediately although I typed in program to "wait until button pressed"
Please help me! Thanks in avance!!!


that sketch you sent me did not work, it was from the older stepper motor driver, from what i can tell.
i think that all i need is the address of the pins (step and Dir) to substitute in when i am assigning motors in the accel stepper sketches, this is what they are requesting…

// MultiStepper.pde
// -- mode: C++ --
// Shows how to multiple simultaneous steppers
// Runs one stepper forwards and backwards, accelerating and decelerating
// at the limits. Runs other steppers at the same time
// Copyright © 2009 Mike McCauley
// $Id: MultiStepper.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $

#include <AccelStepper.h>

// Define some steppers and the pins they will use
AccelStepper stepper1(1, 3, 6); // pin 3 = step, pin 6 = direction
AccelStepper stepper2(1, 4, 7); // pin 4 = step, pin 7 = direction
AccelStepper stepper3(1, 5, 9); // pin 5 = step, pin 8 = direction


I have a few suggestions:

  1. Start a new thread for a new topic. This has nothing to do with the stepper motor thread. :slight_smile:
  2. Upgrade to 3.4.8 (you are running 3.4.1 from your screen shot).
  3. If you are intending to use the onboard pushbutton on the mBot, use the On Board Button [pressed] block. I believe the block you are using is intended for a button connected to one of the ports on the mBot, not the onboard button.
  4. If you continue to have issues after upgrading to 3.4.8, contact @tec_support.