Pages: [1]   Go Down
Author Topic: HC-SR04 analog pin ?  (Read 1580 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all

Just recieved a couple of HC-SR04 sensors.

I was wondering... Is it possible to run theese on the arduino uno anolog pins ?
Or does it have to be on the digital ?

All examples I can find on the net, they are connected to digital pins.
The problem/clue is, when using the L293 motor shield, the analog pins are all unused.

Best regards
Henrik
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 112
Posts: 5286
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I was wondering... Is it possible to run theese on the arduino uno anolog pins ?

Yes. All the analog pins of a standard Arduino can be used a digital I/Os. Most Arduino pins have more than one functionality. For example the pin A4 have three usages: analog input, digital input/output and I2C SDA.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Brilliant. Thank you for the hint  smiley
Logged

Toledo, OH
Offline Offline
God Member
*****
Karma: 36
Posts: 514
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Brilliant. Thank you for the hint  smiley

Also, you can use the NewPing library and control your sensor using only one pin instead of two.  This could also save you in a pinch.  It's also a VERY good idea to use the NewPing library if you're also using motors, as other ultrasonic libraries or code will give you grief as they don't multitask well (or at all) and cause long 1 second delays.

Tim
Logged

Arduino - Teensy - Raspberry Pi
My libraries: NewPing - LCDBitmap - toneAC - NewTone - TimerFreeTone

Pages: [1]   Go Up
Jump to: