Go Down

Topic: hcsr04 on analog pins. (Read 613 times) previous topic - next topic

tawandapro

hello i have A0 to A5 pins free on my arduino uno. can i use them to control 2 HCSR04 sensors or do i need to upgrade to Arduino MEGA? Thanks.

johnwasser

Yes, you can use A0-A5 as digital pins.  Just use the names A0, A1, etc.  They also have numbers (14, 15, etc on the UNO) but the numbers are different on different platforms (Mega, Leonardo) so use the names which will be mapped to the appropriate numbers.

Strangely, some chips have A6 and A7 pins that CANNOT be use as digital pins.  Just something to watch out for.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

giant25


hello i have A0 to A5 pins free on my arduino uno. can i use them to control 2 HC SR04 or do i need to upgrade to Arduino MEGA? Thanks.


I just did this exact thing yesterday.   I  used the NewPing library and set pin 14 as the echo and trigger pin,  which is the same pin as A0.  Worked great.  Putting a jumper to connect echo and trigger allow the HC sr04 to be controlled with one pin.  I then did the same thing with a second sensor and pin 15, aka A1.  Good luck.

Go Up