Arduino Giga R1 WiFi Stepper Motor A4988 Driver
In this guide, we will learn how to build the drive of a small syringe pump with the Arduino Giga R1 WiFi. The Giga counts out pulses, an A4988 driver turns the pulses into motor current, and a NEMA 17 stepper motor turns a lead screw (a long threaded rod). The screw presses on the plunger of a syringe, and a measured dose comes out. In detail, we will learn:
- Which A4988 pins a pump uses, and which ones it leaves empty.
- Why the logic pin VDD gets 3.3V on this board.
- How to connect driver, motor, 12V adapter and Giga: first on an expansion board, then pin by pin.
- How to tune the driver: the step size with three tiny switches, the motor current with a multimeter.
- How to write Giga code that moves the plunger at one speed, and then code that starts and ends every dose gently.

Dosing is counting. A stepper motor answers each pulse with the same small turn, so 200 pulses move the plunger by the same distance today and tomorrow. The Giga only has to remember how many pulses it has sent. A DC motor makes no such promise, and it would need a position sensor for this job.
One warning before we start: this is a bench toy for colored water, plant food or glue. A home-made pump must never give medicine to people or animals.
Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
No expansion board at home? It is an extra, not a must. The second wiring diagram connects the bare A4988. You also need no screw and no syringe today: a paper flag on the motor shaft tells you whether a move was right.
Overview of A4988 Stepper Motor Driver
Sixteen pins, one chip and one trimmer: the DIYables A4988 module holds little more than that. It is red, has the common StepStick shape, and covers just 20 x 15 mm or so. The pins come soldered. The package also holds a small stick-on heat sink, and its place is on the black chip.
| A4988 Driver Module | |
|---|---|
| It drives | a single bipolar stepper (a 6-wire motor works as a 4-wire one) |
| Motor power on VMOT | 8V to 35V DC; this guide uses 12V |
| Logic power on VDD | 3V to 5.5V; this guide uses 3.3V |
| Coil current | near 1A with a bare chip; 2A at most, with the heat sink and good cooling |
| Smallest move | 1/16 of a full step (1/8, 1/4, 1/2 and full are possible too) |
| Inputs it needs | two, called STEP and DIR |
| It protects itself from | overheating, too low supply voltage, crossover current |
| Error output | no FAULT pin |
Your code has an easy life with this chip. Which coil gets current now, and which way round? A block inside the A4988, the translator, knows the whole pattern. The Giga only says "go" and "that way". "Go" is a rising edge on STEP, the jump from LOW to HIGH. "That way" is the level on DIR.
The A4988 also looks after the coils. It watches their current and cuts the supply for a moment whenever your limit is reached. This fast on and off has a name, chopping. Thanks to it, 12V is no danger for a motor that is rated for 2 to 4V.
Pinout

Let's sort the pins by the work they make for you.
Four pins meet the Giga:
- STEP pin: connect to D4. It receives the pulses.
- DIR pin: connect to D3. HIGH is one direction, LOW is the other.
- VDD pin: connect to 3.3V. It feeds the logic of the chip.
- GND pin below VDD: connect to GND.
Six pins meet the power jack and the motor:
- VMOT pin: connect to the plus terminal of the power jack.
- GND pin below VMOT: connect to the minus terminal. Inside the module, this pin and the GND below VDD are one.
- 2A and 2B pins: connect to the two ends of one coil (coil 2 in the picture).
- 1A and 1B pins: connect to the two ends of the other coil (coil 1).
Two pins meet each other:
- RST and SLP pins (reset and sleep): a LOW on either one stops the driver. The module holds SLP at HIGH, but RST floats, which means it has no fixed level. A short link shares the HIGH of SLP with RST.
Four pins stay empty:
- EN pin: the module keeps it LOW, which means "outputs on". A HIGH here would release the shaft.
- MS1, MS2 and MS3 pins: an empty one reads LOW, and LOW on all three means full steps.
Your board may say B2, A2, A1, B1 instead of 2B, 2A, 1A, 1B. The first spelling is on its top side, the second one underneath. The pins are the same.
Why VDD Gets 3.3V
A DRV8825 makes its logic voltage by itself. The A4988 does not, so a wire has to bring it to VDD. With the Giga, this wire starts at a 3.3V pin and never at 5V.
The reason is a simple border line. The driver compares STEP and DIR with VDD: only a signal of more than 70% of VDD is surely HIGH. Give VDD 5V, and the border lies at 3.5V. A Giga pin reaches 3.3V and no more, so pulses could go missing, and each missing pulse makes the dose smaller. Give VDD 3.3V, and the border falls to 2.31V. Now the pulses of the Giga are well above it.
5V would put the Giga itself at risk too, because its pins do not tolerate more than 3.3V. Look at the header of the expansion board: the V column and the S column are neighbors. If you push a jumper into the wrong column, the Giga pin gets the voltage of V.
The Motor: Four Wires, Two Coils
Count the wires of the motor. A bipolar NEMA 17 has four of them, the ends of two coils. The shaft turns 1.8 degrees at every full step, so it is back at the start after 200 of them. Each coil gets its own pair of driver pins:

| Coil | Wire | Our Motor | Other Name | A4988 Pin |
|---|---|---|---|---|
| coil 2 | A | black | A+ | 2B |
| coil 2 | C | green | A- | 2A |
| coil 1 | B | red | B+ | 1A |
| coil 1 | D | blue | B- | 1B |
In some datasheets, the plus ends are plain A and B, and the minus ends are the same letters with a bar on top.
Check these colors against your own motor, since every factory has its own habit. Lost the paper? Let the multimeter find the pairs: a few ohms between two wires says "same coil". It works by hand as well, with the motor unplugged: hold two bare wire ends against each other and twist the shaft. When it suddenly gets hard to turn, these two belong together.
A mix-up inside one pair does no harm, the motor just runs the other way round. A mix-up between the pairs is different: the motor buzzes and shakes without turning.
Step Size
A full step can be too coarse for a slow, even flow, so MS1 to MS3 can divide it. On the expansion board, you do that with the DIP block, one switch per MS pin. The ON side makes the pin HIGH. Mind the numbers: switch 1 belongs to MS3, switch 2 to MS2 and switch 3 to MS1.
| Step | Pulses per Turn | Switch 1 (MS3) | Switch 2 (MS2) | Switch 3 (MS1) | Plunger Moves per Pulse |
|---|---|---|---|---|---|
| full | 200 | off | off | off | 0.01 mm |
| 1/2 | 400 | off | off | ON | 0.005 mm |
| 1/4 | 800 | off | ON | off | 0.0025 mm |
| 1/8 | 1600 | off | ON | ON | 0.00125 mm |
| 1/16 | 3200 | ON | ON | ON | 0.000625 mm |
The last column belongs to our example screw, which moves the plunger 2 mm in one turn. As the steps get finer, the motor gets quieter and the liquid flows more evenly, but a dose then takes more pulses. The code has to know about it. Whenever you flip a switch, change MICROSTEPS as well. For this guide, leave all three off.
Wiring Diagram
There are two ways to build the drive, and both use the same Giga pins. So the same code runs on both.
Build 1: A4988 on the Expansion Board
This 42 x 42 mm board takes over the boring part of the work. It has sockets for the module, screws for 12V, a plug for the motor and the DIP block. It also carries a 100uF / 35V capacitor, and it links RST with SLP. Four jumper wires to the Giga are all that is left.

This image is created using Fritzing. Click to enlarge image
※ NOTE THAT:
- The sockets accept the module both ways round, but only one way is right. Its EN-to-DIR row sits next to the G V S header, and its VMOT pin sits at the little arrow marked "VIN". Turned around, the module can be destroyed.
- An A4988 gets no logic power without the V wire. (On the same board, a DRV8825 does not need it.)
- Unplug 12V before you plug in or pull out the motor. Under power, this makes a voltage spike that the A4988 may not survive.
| From | To the Expansion Board |
|---|---|
| Giga D4 | STEP row, S column |
| Giga D3 | DIR row, S column |
| Giga 3V3 | V column, any row |
| Giga GND | G column, any row |
| nothing | EN row, S column (empty = driver on) |
| power jack, plus | VIN screw |
| power jack, minus | GND screw |
| coil 2, wires A and C | motor plug, 2B and 2A |
| coil 1, wires B and D | motor plug, 1A and 1B |
Some hints for the picture:
- It puts both V and G into the EN row. Any other row is just as good, because each of these two columns is one line on the board.
- Its 3V3 comes from the small header close to the USB ports, and its GND lies between pin 13 and AREF. Each 3.3V pin and each GND pin of the Giga does the same job.
- Brown, yellow, pink and purple are only there to tell the motor wires apart on paper. For your motor, the coil table decides.
- The VIN screw is the one and only entrance for 12V (its label says 12-24V). Keep 12V away from all Giga pins. Giga, driver and adapter share one ground, and the board joins them.
Build 2: The Bare A4988
Now every pin is wired by hand. Two things from the expansion board are missing, so you bring them yourself:
- The link from RST to SLP. The picture shows it in orange. If you forget it, the pump stays silent.
- A capacitor of 100uF (35V or more is the best choice) right beside the module: plus leg on VMOT, minus leg on the GND below it. It is not drawn, but please add it, because it catches the voltage spikes on the 12V wires.

This image is created using Fritzing. Click to enlarge image
| A4988 | Goes To |
|---|---|
| STEP | Giga D4 |
| DIR | Giga D3 |
| VDD | Giga 3.3V |
| GND, below VDD | Giga GND |
| VMOT | power jack, plus (12V) |
| GND, below VMOT | power jack, minus |
| 2B and 2A | coil 2 (wires A, C) |
| 1A and 1B | coil 1 (wires B, D) |
| RST and SLP | each other |
| EN, MS1, MS2, MS3 | stay empty |
In this picture, 3.3V is taken from the header that also has RESET and 5V. The 5V hole follows directly after the 3.3V hole, so look twice. The GND is the last hole of the long double header, after 52 and 53. The pins of the module are male, so use wires with a female end there, or put the module on a breadboard. Do you want microsteps? Then run a wire from 3.3V to the MS pins that must be HIGH.
Whichever build you choose, 12V comes last: the adapter goes in after all the other wires have been checked.
Set the Current Limit
Do this once before the first run. The adapter is still out, and the USB cable alone powers the Giga and VDD.
The trimmer with the cross slot decides how many amps a coil may get, and a small voltage called VREF shows its setting. The A4988 works with this rule: current limit = VREF / (8 x Rs). On the DIYables module, the sense resistor Rs has 0.1 ohm (there are two of them, printed R100). Turn the rule around and you get VREF = 0.8 x current. So 0.36V stands for 0.45A, 0.52V for 0.65A and 0.76V for 0.95A. If the print on another brand says R050, multiply by 0.4 instead.
- Look for "current per phase" in the papers of your motor. Stay below that number, and below 1A while the heat sink is off.
- Set the multimeter to DC volts. Black probe: any GND. Red probe: the metal head of the trimmer.
- Turn the trimmer only a little with a fine screwdriver, then read again. The blade must not touch the parts next to it.
- Choose a low value for the first run, for example 0.36V. Raise it later if the syringe needs more force.
A pump rests a lot, but its motor does not. Between two doses it holds the plunger with current, so driver and motor warm up although nothing moves.
How To Program For A4988 Stepper Motor Driver
Plain digitalWrite() is enough to turn the motor:
- Name the pins and let the code work out how many pulses one turn takes:
- In setup(), make them outputs:
- Decide the direction, and give the driver a few microseconds to see it:
- Send one step. The Giga is fast, and the A4988 wants each level for at least 1 microsecond. We stay at each level for 2000 microseconds, because this waiting time is also the speed control:
- Put these four lines into a for loop that counts to STEPS_PER_TURN. That is one full turn.
Every step lasts 4 ms, which makes 250 steps per second, or 75 turns per minute. A NEMA 17 can jump to this speed from a standstill. For more speed, or for a gentle dose, it needs a ramp. The AccelStepper library calculates this ramp for you:
- Describe the hardware. The word DRIVER tells the library that a STEP / DIR chip does the coil work:
- Fix the limits of the movement in setup(). The three numbers are microseconds, steps per second, and steps per second gained in each second:
- Name a target, then keep calling run() until the distance is 0. A call sends one pulse or none, and it must come often. That is why no delay() is allowed in this loop:
Arduino Giga R1 WiFi Code - A4988 Stepper Motor Driver
Before any liquid is involved, test the drive. This sketch makes strokes: one turn in the push direction, a 1.5 second break, one turn in the pull direction, another break, and so on.
Detailed Instructions
Follow these instructions step by step:
- New Giga on the desk? Its board package must be in the IDE first, see Arduino Giga R1 WiFi getting started.
- Wire the components according to the provided diagram. DIP switches: all off. Adapter: unplugged.
- Make a flag of paper tape on the motor shaft. Screw and syringe are not mounted yet.
- Connect the Giga R1 WiFi to the computer by USB Type-C, and adjust VREF now.
- Launch the Arduino IDE on your computer.
- Select the appropriate Arduino Giga R1 WiFi board (e.g., Arduino Giga R1 WiFi) and COM port.
- Paste the sketch and press Upload.
- Now the 12V adapter may go in, and the flag starts to turn.
- Open the Serial Monitor (9600 baud) to see which stroke is running.
Make a pencil mark behind the flag while it rests. A stroke takes 0.8 seconds, and at its end the flag must cover the mark again. A flag that stops at the half or the quarter of a circle means that a DIP switch is on while MICROSTEPS is still 1.
"Push" is only a word in the code. If it pulls on your machine, change the two levels in movePlunger(), or turn around the pair on 2A and 2B (12V out first).
Do not worry if the first line is missing. The USB port of the Giga reconnects after an upload, and the Serial Monitor may open a moment too late for it.
Arduino Giga R1 WiFi Code - Syringe Pump with AccelStepper
A jerk is bad for a pump: the nozzle drips, the tube shakes, or the motor skips a step. So here the plunger gains speed slowly and loses it slowly. The cycle goes like this:
- The plunger pushes out five doses. One dose equals one turn of the screw.
- It rests for 2.5 seconds after each of them.
- It travels back to step 0 in one piece.
- After 6 seconds, the next cycle begins.
The library comes from the Library Manager:
- Open the Libraries panel of the Arduino IDE.
- Look up "AccelStepper" and pick the entry by Mike McCauley.
- Press Install.
- Search for AccelStepper created by Mike McCauley
and click the Install button.
Detailed Instructions
- The wires stay where they are. Take the 12V plug out for the upload.
- Upload the sketch and keep the Serial Monitor at 9600 baud.
- Move the flag back to the pencil mark by hand, then plug in 12V.
- Tap the RST button of the Giga one time. Without motor power, the sketch was already counting doses that nobody saw. After the reset, it starts again at step 0.
Listen to the motor. Each dose takes about 1.3 seconds and never gets fast: after 100 steps, at about 300 steps per second, it is already time to brake. The 1000 steps of the way back leave more room. There the pitch climbs, stays at 640 steps per second for a short moment and sinks again, all in about 3 seconds.
How Much Liquid Is One Dose?
The screw and the syringe decide:
mL per turn = travel per turn (mm) x plunger area (square mm) / 1000
An example: a screw with 2 mm per turn, and a syringe that is 16 mm wide inside. The area is 3.14 x 8 x 8, so about 201 square mm. Two millimeters of it are 402 cubic mm, or 0.4 mL. Five doses give about 2 mL. For doses of 0.1 mL, write STEPS_PER_TURN / 4 as the value of DOSE_STEPS. A kitchen scale checks your result, since 1 mL of water weighs 1 gram.
※ NOTE THAT:
For the sketch, step 0 is simply the spot where the plunger is at power-on. It cannot feel the end of the syringe. Turn the screw back by hand (12V unplugged) until all five doses fit in, and only then start a real run.
Troubleshooting
| What the Pump Does | What to Look At |
|---|---|
| No dose at all, the shaft turns freely by hand | 12V plug, V or VDD wire, and (bare A4988) the RST-SLP link |
| Buzzes and shakes on the spot | coil pairs mixed up, VREF too low, or TOP_SPEED / ACCELERATION too high; take 12V out before you touch the motor wires |
| Pulls when it should push | one coil pair is reversed; exchange its two wires |
| Pauses by itself, driver very hot | overheating shutdown; lower VREF, add the heat sink, give it air |
| Doses are 2, 4, 8 or 16 times too small | DIP switches and MICROSTEPS disagree |
| Does not come back to the mark | steps get lost; lower ACCELERATION, reduce the load, or raise VREF within the motor rating |
Where the pump can go from here:
- A rear stop: let a limit switch tell the Giga where step 0 is, so nobody has to set the plunger by hand.
- One press, one dose: the button debounce guide keeps a bouncing button from giving two.
- A dose knob: read a potentiometer and turn its value into DOSE_STEPS.
- A cool-down: put EN on a free Giga pin and make it HIGH after the last dose. The shaft is loose then, so test first whether the plunger stays in its place.
Is the A4988 the right driver? For a 12V pump with less than 1A per coil, yes. The DRV8825 is its bigger brother: 8.2 to 45V, about 1.5A (2.2A when cooled), steps down to 1/32, and no wire for logic power. It listens to the same STEP and DIR and fits the same expansion board. And when a motor only has to spin, like a stirrer beside the pump, take a DC motor and the Arduino Giga R1 WiFi - BTS7960 Motor Driver guide.