Introduction: How to Add 6 Extra Pins to Your Arduino With No Extra Hardware

Hello, this is my second Instructable so please bear with me.
I am going to tell you how to get 6 extra Arduino digital pins.
I discovered this by playing with the Arduino IDE and tried setting up a LED on pin 14 (which does not exist on the board) And guess what? Analog pin 0 is pin 14!

Step 1: How to Get the Other Analog Inputs Working Too

It is pretty simple to get the others working too! Here is a list of all of the pins:

Pin 14 = Analog in 0
Pin 15 = Analog in 1
Pin 16 = Analog in 2
Pin 17 = Analog in 3
Pin 18 = Analog in 4
Pin 19 = Analog in 5

Unfortunately these are not PWM pins, but you can use the SoftPWM library to get software-based PWM, which is almost as good as native PWM.

Step 2: The Example Code

Here is just an example code i wrote for testing:

int ledPin = 14;
int gndPin = 15;
void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(gndPin, OUTPUT);

digitalWrite(gndPin, LOW);
}

void loop()
{
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
}

Comments

author
KristenT22 (author)2017-03-24

Thanks for taking the time to post, is obvious but still I may have missed it in the documentation and android assistant pointed me to this instructable and now I have more pins to play with. So much to learn, thanks again

author
sighsigh (author)2016-11-24

Thanks, I was running out of digital pins.

author
AqsaB (author)2016-08-17

what if i want to give two different inputs to pin 0 and 1?

author
wasp95 (author)2016-03-29

Will this work for bluetooth hc 05 if I give tx rx to any two analog pins using the digital function.I am using serial I cannot use pin 0 and 1 as it creates conflict(which I myself didn't really understand).i need to control servos using bluetooth app.

author
FullSoundBox made it! (author)2016-01-09

Thank you, I was getting some problems trying to use the analog 0 and 1 pins for reading a digital sensor, now works just fine.

Capture.PNGCapture.PNG
author
ReCreate (author)2009-10-27

Its nothing new, Its already on the board >_<

author
RichardBronosky (author)ReCreate2014-07-10

I actually found this instructable by Googling for the answer to my question I asked over on Sparkfun. So, I for one appreciate the time he spent making this. I'm new to hardware and EE. There is so much mystery in it (especially the Arduino) for me.

author

There is not many mystery in Arduino -_- study microcontrollers.These are all same

author

That's pretty arrogant. There is plenty of mystery. There are numerous resources dedicated to it. This happens to be one of them. The whole point of Arduino is to make microcontrollers approachable to the people who learn by doing. Finally, they are not all the same. They are subtly different and therein lies the mystery.

There was just nothing good or true in your comment. Why do people feel the need to leave comments like this? "Look, a person on the internet does not know something that I know. -_- Grr, that makes me angry. I must strike them down."

author
Sire_74 (author)RichardBronosky2016-01-07

I second that. Learning Arduino (and it's programming) is not that easy if you're a noob. It might be kiddy stuff for those who knows their way around more advanced electronics, but for people who'd never tinkered with this before, no.

author
sdcharle (author)RichardBronosky2015-01-10

Actually Instructables is usually one of the better sites as far as not having comments from the electronics equivalent of the Comic Book Guy from the Simpsons. Unfortunately a couple of them squeeze through...

author
GencayC (author)2015-12-10

Also works with the nano.

author
rabiuls (author)2015-11-30

For Arduino Mega, analog pin's digital number is as:

A0 = 54
A1 = 55
A2 = 56
A3 = 57
A4 = 58
A5 = 59
A6 = 60
A7 = 61
A8 = 62
A9 = 63
A10 = 64
A11 = 65
A12 = 66
A13 = 67
A14 = 68
A15 = 69

author
RichardBronosky (author)2014-09-25

I'd like to point out that with the SparkFun Arduino Pro Micro it is:

A0 = D18

A1 = D19

A2 = D20

A3 = D21

For the Leonardo also gain:

A4 = D22

A5 = D23

A6 = D24

A7 = D25

A8 = D26

A9 = D27

A10 = D28

A11 = D29

author
josefdz (author)RichardBronosky2015-11-12

Hello RichardBronosky can you give an example on how to do a simple code to read A1 Pin as a Digital pin?

Thank You.

I did this, but is not working.

void setup()

{

Serial.begin(9600);

pinMode (A1, INPUT);

}

int DIGITAL;

void loop()

{

DIGITAL = digitalRead(A1);

Serial.print(DIGITAL);

delay(500);

}

author
diy_bloke (author)josefdz2015-11-29

dont define it as A1 but as D15

author
PumaBare (author)2015-08-20

Thank you, this just answered a question I was asking in regard to the arduino pro-mini, normally only 14 digital outputs and I need 16, seems this solves it for me, cheers!

author
genezis (author)2015-08-05

You can use 4 additional digital pins in Arduino Micro:

MISO = D14

SCK = D15

MOSI = D16

SS = D17 (orange LED conneted on board)

author
AhmedM46 (author)2015-07-11

Thanks so much you solve a big problem faced me

author
coolersport (author)2015-04-25

If anyone would like more output pins, you could utilise a demultiplexer. See following:

http://en.wikipedia.org/wiki/Multiplexer

http://www.ebay.com.au/itm/10-pcs-CD4051BE-CD4051-4051-IC-16-pins-CMOS-Multiplexer-Switches-Demultiplexer-/371116027139?pt=LH_DefaultDomain_15&hash=item56683d2d03

http://pdf1.alldatasheet.com/datasheet-pdf/view/26882/TI/CD4051BE.html

author
GerrieH (author)coolersport2015-05-03

Adding shift registers is also a inexpensive and easy option.

author
SideTracked350 (author)2015-03-19

Fantastic!! I was trying to find out if I could sub the analogs for digitals. strangely I had no success in finding a straight forward answer and thus wrote it off, and now stumbled on this while looking for something else HAHA. This saves me from having to incorporate another board. Thanks a bunch for sharing. any idea how one might get them to chase like Christmas lights for a time period as a sub routine to a sketch?

author
GR0B (author)2013-09-26

Thanks for sharing, I knew you could control the pull up of an analog but didn't know it also had a digital pin number too.

author
DustinT (author)GR0B2015-01-14

Same here. The fact that analog pins can be used as digital is well documented. I was a bit annoyed by the title at first, but this is good info.

author
daniel.huebner.96 (author)2014-12-21

awesome just what i needed, more pins.

author
DouglasF (author)2014-11-27

I am Brazilian student. thanks for the help always has excellent tutorials

author
Nickson Yap (author)2013-09-07

Thanks!
btw, in SoftPWM, you can write it as pin A1 and it works just as well as pin 15.

author
oqla2000 (author)2011-07-22

Good info thanks !

author
'jaiswal (author)2011-04-28

thanks for the information.....as all know that "analog pin can be use as digital" is already on arduino.cc....... but helpful info. is that A0 is pin 14...that is not given on site... :)

author
neutron7 (author)2010-03-18

On the MEGA the anlog pins are digital  53,54,55 etc.

author
Grathio (author)2009-11-04

It's new to me!  Thanks for sharing!  I know this will come in handy!

author
davidbuzz (author)2009-10-22

it's also on this page:  www.arduino.cc/en/Guide/Board  whereit says :
" Most of the analog inputs can also be used as digital pins "

author
belectric23 (author)2009-10-21

News to me - thanks for the tip!

author
mikemmcmeans (author)2009-10-17

neat, but what about the arduino MEGA's?
they have digital pins up to 53 and analog pins upto 16

author
Dege (author)2009-10-08

 It's already in the arduino documentation but it's a bit hidden:
http://arduino.cc/en/Reference/PinMode
(watch the note at the end of the page...)

author
Noodle93 (author)2009-10-06

Yeah, this is pretty well known.

author
ikestarm17 (author)2009-10-05

that's pretty cool and is very helpful. Thanks!

About This Instructable

144,706views

61favorites

Bio: I'm a software developer, but I also love tinkering with electronics. My Instructables are all about Arduino.
More by baharini:ATTiny45/85 LCD display control with a shift register, programmed in ArduinoControlling a character LCD with an ArduinoHow to add 6 extra pins to your Arduino with no extra hardware
Add instructable to: