Arduino analog pins to digital explained

Last Updated on March 16, 2024

Using arduino boards in projects, looking for additional digital pins then this article helps you to get extra digital pins.




When we use arduino uno, genuine, or duemilanove board we get 14 digital pins, if we use LCD display means nearly 8 digital pins occupied by LCD terminals. Hence there is shortage of digital pin rises. By using simple program we can easily convert analog input pin as digital output pin.

analog-to-digital-new                                analog-pin-digital-pin-new

Every arduino uno board have analog pins from 0 to 5. Put equivalent digital pin number as given

Analog in 0 = pin 14

Analog in 1 = pin 15

Analog in 2= pin 16

Analog in 3 = pin 17

Analog in 4 = pin 18

Analog in 5 = pin 19

Declare these pin numbers as integer (int) in arduino sketch, now make any analog pin as digital output pin. These pins will act as non pwm digital pins.

If you want to increase PWM pins in arduino board use softpwm library.

Arduino Code

 

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

digitalWrite(gndPin, LOW);
}

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

Prototype

analog-digital-pin-new
 



2 thoughts on “Arduino analog pins to digital explained

  1. thanks for sharing this awesome info , your article is excellent and informative , keep it up with such great content content

Leave a Reply

Your email address will not be published. Required fields are marked *