-1

Im a complete beginner

Im making a project using relay modules and arduino. but all the digital pins of my arduino are filled. I wanted to ask if i can use the analog pins to connect my relay module to my arduino? If yes can anyone give me the statements to write high and low using analog.

1
  • 1
    pins that have analog functionality are multi purpose ... they can also be used for digital outputs ... the command is the same for all digital output pins
    – jsotola
    Dec 26 '20 at 9:47
3

Yes, you can use the analog pins as digital pins. Quoting this Arduino tutorial:

pinMode(A0, OUTPUT);
digitalWrite(A0, HIGH);

EDIT:
Here is the code snippet for digital input:

pinMode(A0, INPUT);
digitalRead(A0);
2
  • Your answer is certainly correct, but it would be better to show an example of using an analog pin as a digital INPUT, since that's what the OP is asking about.
    – Duncan C
    Dec 26 '20 at 12:55
  • worked for me thanks Dec 26 '20 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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