Creating 160 additional gpio pins from arduino mega


Mega has 70 IO pins (D0-D53, A0-A15 are also D54 to D69). So 17 4-wire steppers.
Add a couple more, with one acting as master telling the others where to go.
Not sure how many steppers can be controlled smoothly from one processor.
I’ve done 7 with Atmega1284P and it’s 32 IO lines:
(delete the extra characters the forum adds to the start and end of the link)

A board that breaks out all 86 Atmega1280 or Atmega2560 IO pins could potentially control 20 4-wire steppers.

You could write the code to make that many move, and just wire up 1 or 2, and see how smooth they look.

For example, I wrote this up as an expansion of the 1284P code to see if would compile as a starting point:
(code attached, too large to embed in a post)

Atmega2560_17motor.ino (14.6 KB)

You can also use way more than 4 shift registers with a Mega.
I did a project with 45, driven by SPI bus (SCK, MOSI, SS) at 8 MHz.
You wouldn't connect shift registers to the I2C bus.

Use stepper drivers that only need step and direction inputs. That uses half as many pins. Then there are I2C expanders like the MCP23017 (16 gpio pins each). There can be 8 of those on the I2C bus (128 pins). Or the SPI version, MCP23S17.

You can daisy chain more than 4 shift registers (ie. 74C595) on the SPI bus.

Is your project so simple that a single controller can handle all active motors at the same time?

Did you already test how many stepper motors a Mega can control at the same time with its own pins?

You can daisy-chain shift registers on SPI bus. You will need motor drivers and external power as well, at least ULN28xx chips.

35 stepper motors and $50 budget? What are you smokin?

Right, also stepper motors are inappropriate for wearables.

After all I wouldn't wonder if it should become kind of a powerful exoskeleton :wink:

Stepper motors cannot be driven directly by gpio pins. The current required is far too high for gpio pins. Some form of driver chip or module is required. The most basic driver chip such as ULN2803 require 4 pins, but most only require 2 pins per motor. These drivers can halve the number of pins required.

Have a look at pcf8574 chips. These have 16 gpio pins each and up to 8 can be connected to the same i2c pins on the Arduino, giving 128 extra pins.



Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you take a few moments to Learn How To Use The Forum.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum.

See Two Wire Control on this page as well
You may be able to get away with fewer IO pins, at the expense of likely having to wire up a ULN2003/ULN2803 ULN2004/ULN2804 (data sheet says lower input required) and some resistors per motor if you have smaller Unipolar motors.

What are you making that has 35 wearable motors?

Or search words (in quotes)
"ebay 10/50/100PCS ULN2003APG DIP-16 composite transistor IC ULN2003 AN"

Set pcs/lot to 50 and 1 lot of 50 costs US$4.99 plus $3.90 shipping.

If you run a motor enough you could need a heat sink of some kind on that driver chip.

If only some of the motors ever run at the same time there might be ways to save on parts.