Analog Pin Like Digital Pin, is possible?

Hi, :slight_smile:
i have ArduinoUNO, i have to connect to this Arduino, 5 Ultrasonic Sensor (HC-SR04), but i don't have enough free Digital Pin, but instead i have all the Analog Pin free, can i use this Analog Pin to connect the Ultrasonic Sensor?
How i have to initialize this pin?
and how i have to setup it in the "Setup" funcion??

Please Help Me :cold_sweat: :cold_sweat: :cold_sweat:

Please insert your code

Sure you can use analog pins as digital input or output pins.

In your setup() function set the pin mode desired for the pins you use, example:

pinMode(A0, OUTPUT); // lets use analog pin 0 as a digital output pin
pinMode(A1, INPUT); // lets use analog pin 1 as a digital input pin
...
...

Then in you main sketch you can then do stuff like:

digitalWrite(A0, HIGH);
int myVariable = digitalRead(A1);

Lefty

hi

#define trigPin A0
#define echoPin A1

void setup()
{
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}

or

int trigPin = A0;
int echoPin = A1;

void setup()
{
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}

regards