1

This question already has an answer here:

Hey guys I have a project that will require 20 I/O pins with serial communication from a computer to control each of the pins. I would like something as small as possible would a arduino micro or uno work for this project or will i need to go bigger like a mega. I have looked at all the pinouts but am confused to know of which pins I can use as digital I/O or not. Thanks

marked as duplicate by sa_leinad, MatsK, gre_gor, VE7JRO, Juraj Apr 3 '18 at 8:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    rarely do you need 20 IO pins if you play your cards right; i have an LCD, INA219 module, a button and an LED on one ESP-01. Take advantage of i2c, ws2812, charleyplexing, etc, then use expanders or pro-minis if needed. – dandavis Mar 29 '18 at 2:13
  • i would also consider an ESP32. you can disable wifi, and it's still a beast of an arduino; it can do your 20GPIOs, and even a devkit is much smaller than a mega, for about the same price or less. The raw power makes coding easier since higher level instructions run plenty fast enough (String class, double, serialized objects in SPIFFS vs EEPROM structs, etc). And who can complain about hundreds of KB of RAM? – dandavis Mar 29 '18 at 2:25
  • @Cameroony Please see the link above for answers to a pretty similar question. Hopefully you get some answers there. If this is not a duplicate, please edit your question and let us know how your question is different. – sa_leinad Mar 29 '18 at 8:54
3

If you require 20 I/O pins then use Arduino Mega. If it’s too big then use Nano, Micro or Pro Mini (you need a serial thingy to program the Mini) with I/O expanders like PCF8574P with I2C communication or MCP23S17 with SPI communication.

2

There are a couple of options

  1. Easiest = Use an Arduino with a greater number of pins (e.g. MEGA2560)
  2. Easy = Use an add-on board (e.g. Teensy)
  3. Harder = Use shift registers (see Is there a way to have more than 14 Output pins on arduino?)

Further discussion on these options here.

Not the answer you're looking for? Browse other questions tagged or ask your own question.