how to run a steppermotor with a gt2560 board?

Hi guys,

Can anybody give me some help please?

I have 3 steppermotors (NEMA 17 Model: 42SHD0217-24B) and a gt2560 board with A4988 stepper driving modules.

I installed Marlin and if i turn the board on the motor makes some noise so i think it's connected well.

I don't have the rest of the parts needed for a 3d printer, i want to use the motors for a cleaning robot.

Can anybody give me the code to let let one motor run? It 's connected to the X-axis connector and has to run full speed clockwise so i can test my robot. Thanks a lot!

What is a gt2560 board? Post a link to its datasheet.

You could try this Simple Stepper Code to test the motors.

If the board is intended to work with Marlin and if Marlin is suitable for your application you need to seek advice on a Marlin Forum or maybe on the RepRap Forum.

Marlin is a large and complex "off the shelf" program. The Arduino Forum is for helping people write their own programs.

Stepper Motor Basics

First you have to determine how fast 'full speed' is in millimeters per minute.

Use the G90 or G91 command to switch to absolute or relative coordinates.

Then you send a G1 command to move the X axis to a specified position (absolute) or a specified distance (relative) at the specified speed.


GT2560 is a compact board that is integrated with the mighty function of the Arduino Mega2560+Ultimaker and Arduino Mega2560+ramps 1.4

I wanted to build an arduino robot who can do gardenwork. So i bought this board plus 3 steppers to drive brushes who clean the driveway.

Now i realise that this is not a normal Arduino board, i don't see how i can put shields on it.

Also i can't use the examples of the stepperdrivers because i have no idea what pins the motors are connected to, it only writes X-axis.

Can i run this board with normal arduino language? I have never used marlin and want to learn arduino to upgrade the robot with sensors and much more. Or should i buy another board to build my robot?

This robot has to do lawnmowing, sweeping floors, chase wild dogs and spray them with water...all automatic and controlled by computer every day again. Can an arduino do that or do i need a bigger system?
For the wheels i have a roboteq fbl2360 controller which is also programmable. It uses basic as language which i was very good at 30 years ago. I thought arduino would be simple as well but i even can't make a simple motor run with it.

@Johnwasser, yes i think you posted what i need...just code to let the motor run..i'll go study that now. I only need the motor to run clockwise, nothing else since i connected a brush to it.

Thanks for the help guys, if you have other suggestions how i should control my robot then let me know please. If this thread is in the wrong forum then feel free to move it if you can.

As far as I can see from a quick look at the GEEETECH page that is a normal Arduino Mega with extra hardware so I would expect that it could run any Arduino program.

You will probably need to study the schematic carefully alongside the Arduino Mega pin-map diagram to figure out what things are controlled by what Arduino I/O pins.


Also i can't use the examples of the stepperdrivers because i have no idea what pins the motors are connected to, it only writes X-axis.

Since it works with Marlin firmware I expect it is wired the same as a RAMPS shield. See:

#define X_STEP_PIN 54
#define X_DIR_PIN 55
#define X_ENABLE_PIN 38

I tried to run the testprogram for steppers with the pinout from John but i got an error…that was fixed by upgrading to arduino 1.6.9 (from 1.6.8).

Now the program doesn’t give any errors but also the motor won’t move.

I found a big forum from Geeetech and asked there for the pinout just to make sure i use the right pins.

I tried to run the testprogram for steppers with the pinout from John but i got an error...that was fixed by upgrading to arduino 1.6.9 (from 1.6.8 ).

Which test program? The Arduino Stepper library doesn't support Step and Direction drivers like the ones you have. The AccelStepper library (AccelStepper: AccelStepper library for Arduino) supports the Step/Direction/Enable interface. You pass the Step and Direction pins when you create the instance and then call .setEnablePin() to set the Enable pin.

// Global:
AccelStepper MyStepperX(AccelStepper::DRIVER, 54, 55);
// In setup():

Thanks John, i installed the accel stepper library and tried some examples of it with your latest code.

The motor still won't run but now some red led's on the board do what the program wants the motor to do like change speed or constant speed, they flash in that way. I had never seen those led's before.

I will try some more examples to see if i can get the motor to run.

Where are the LEDs? I don't see any in the GT2560 manual ([](http://" Manual of GT2560.pdf")).

Do you have the 12V to 24V stepper/heater power supply attached?

Hi John,

The red led's are under the green connectors for the heatbeds, i also had never seen them. They flash on the pulses which should make the motor run. They go different speeds or patterns.

Yes i have 19V 3A on the power connector.

The Geeetech forum also gave me help but i still can't find their official pinlist:

The GT2560 manual says that the GT2560 is equivalent to the Arduino MEGA 2560 with a RAMPS 1.4 shield, as I presumed earlier.

Show your test sketch. Perhaps you made a programming mistake.

// Bounce.pde
// -- mode: C++ --
// Make a single stepper bounce from one limit to another
// Copyright (C) 2012 Mike McCauley
// $Id: Random.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $

#include <AccelStepper.h>

// Define a stepper and the pins it will use
AccelStepper stepper; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
AccelStepper MyStepperX(AccelStepper::DRIVER, 54, 55);

void setup()
{ MyStepperX.setEnablePin(38);

// Change these to suit your stepper if you want

void loop()
// If at the end of travel go to the other end
if (stepper.distanceToGo() == 0)

Okay this is what i did, it is possible though that i didn’t connect my stepper properly since it had different colored wires. But the motor moves at startup. I think the stepperwires are connected good but not sure untill i see the motor run for it’s first time.

Can you post the pins.h file from Marlin? I think the GeeeTech guys are saying that you can figure out the pin usage from that.

You could also use a multimeter to see if pin 54 on the Atmega2560 (after figuring which hardware pin is Arduino 54) connects to the STEP or DIRECTION pin of the A4988 socket.

I think you need to ask the GeeeTech guys for a diagram mapping the A4988 pins to the Atmega 2560 pins.

All this will be obvious from a schematic diagram for the board.


The pins.h from Marlin is the same one as the guy from Geeetech is referring to.

I checked that list but didn’t see the gt2560.

What i actually hoped is to use this board as my arduinocomputer for the robot. I want to connect an Odroid XU4 and many sensors to it but if i don’t know what pins i can use that will make it much more complicated.

I would like to connect ultrasonic sensors to the pins of my board and use them. For that i have to know which pins i can use on which connector.

Or i would like to connect an actuator to the heatbedsocket but without a good scheme it will be very hard to find out which pin is what.

So what i use now is the gt2560 with 18V 3A battery connected, usb is connected to this laptop, one stepper motor is connected to the X-Axis socket. That’s all.

Some of the example-programs work on my board and make the led’s flash, other exampleprograms do nothing, even not with the code from John copied into them.

pins.h (74.7 KB)

Pins.h is attached to my previous post.

Here you can see the stepper connected to the brush. It’s mounted on an actuator, on the other side is the lawnmower motor from makita, also on an actuator.

Do you think this 3d printer nema 17 steppermotor is strong and fast enough to spin the brush? Diameter of the brush is about 25-30 cm and it has to spin 2-3 rounds a second i think. The brush has to sweep dirt to the middle of the robot where another brush collects it.

I have no idea whether the motor is adequate to drive that brush. To know that you need to know the torque required to rotate the brush and the speed of the brush.

I presume your board is the same as the Mega 2560 pin assignment that starts at line 461

It should be easy to check that with a multimeter as I suggested previously.


Well i don't know the torque needed to turn that brush. If i can feel the torque of the steppermotor by hand then i can tell if it's enough or not. So it's important to let it run now before i finish my robot.

I measure 18V on the outlet from the X-axis, i even swapped the wire-couples for the stepperconnector but it still won't run. It's holding the axis though.

I asked that expert on the Geeetech forum what can be wrong. Hope he can help. Guess i 'm the only person who bought this board and not use it as a 3d printer. I also wouldn't know how to connect a sensor to this board since i have no idea what pins they all are.

since i have no idea what pins they all are.

Why have you not studied the Pins.h file ?

If you want to use hardware for an unusual purpose you have to be prepared to dig your foundations yourself.


Simply because i can’t :slight_smile:

I can’t find line 461 and i even can’t find the gt2560 in the list of controllers. Maybe the program doesn’t open good in my notepad but it’s just a big mess of numbers that whole file.

Or maybe i’m too spoiled by using Windows for 20 years?

Anyway, i think Arduino is not what i expected of it. If it’s soo hard to let a simple motor run, even with the help of the experts of this forum than i better find another solution.
I want to connect much more to my robot and i’m not going to study and measure which pin is what every time i want to connect something.

This reminds me of 30 years ago when computers were new and we had to figure it all out ourselves.

I still don’t know what Arduino stands for but it’s sure not as easy that even kids can build their own robots like i saw in advertisings.
Also the board i purchased should not be called Arduino because it’s a misleading term. It doesn’t even have any manual with it or nothing and if i ask Geeetech for the pinout they give me a page of algebra where i have to find it.

I have another small motorboard from Arduino but it needs a real Arduino since it’s a shield. That gt2560 board doesn’t have any pins for shields so it’s useless anyway for me.

Well it would be nice to see my motors run before i install the brushes in the robot and all the rest around them.

Which arduino boards should i buy to be sure my motors will run within 5 minutes? I have 3 of those Nema 17 steppers for 3d printers that i want to connect.