Arduino-Using Shift Registers With Ultrasonic Sensors

13,104

56

5

Introduction: Arduino-Using Shift Registers With Ultrasonic Sensors

About: I like to make everything and anything! from electronics to food! and i'll be showing you all the things i come up with here! Twitter: @ERILtech

The HC-SR04 Ultrasonic range sensing module is great for sensing distances that can be used as an input for your Arduino projects, but using multiple (more than two) can quickly cost you a lot of pins.

This basic Instructable gives you the code and basic instructions to use the 74HC595 8 bit series to parallel shift register so you can connect up to 8 HC-SR04 modules (16 IO pins) while using only 4 Arduino IO pins

Step 1: Arduino Code

^^Basic layout of shift register IC and picture with only one HC-SR04 sensor^^

The attached File contains the needed Arduino code and pin layout (scanping)

Also attached is basic code for using the HC-SR04 Ultrasonic range sensing module (ping)

REVISION

Please follow new schematic above^^^ all echo pins must go into transistor circuit

Sensors Contest

Participated in the
Sensors Contest

Gadget Hacking and Accessories Contest

Participated in the
Gadget Hacking and Accessories Contest

Be the First to Share

    Recommendations

    • The 1000th Contest

      The 1000th Contest
    • Battery Powered Contest

      Battery Powered Contest
    • Hand Tools Only Challenge

      Hand Tools Only Challenge

    5 Discussions

    0
    Reinbert
    Reinbert

    6 years ago on Introduction

    Have you ever tried that with more than 1 sensor? Can't confirm that through your photos.

    I tried hooking up 2 sensors to the same echo line to save an input pin but would trigger them one after the other through separate trigger pins. What I found out is that the echo line would never go to high because the unused sensor is keeping the line low.

    What probably would work is triggering all sensors at the same time and evaluate each echo separately. But I don't fancy programming that in an Arduino environment.

    0
    quadracycle4000
    quadracycle4000

    Reply 7 months ago

    Can you use a diode instead? I don't see a point to using an NPN, with both the base and the collector connected together. Also your transistor diagram is rather confusing, because it doesn't clearly show where B is connected. Thanks

    0
    MrSirLRD
    MrSirLRD

    Reply 6 years ago on Introduction

    I originally only tested it with 1, but later used two and had the same problem but found a way to (kinda) fix it and completely forgot to update this instructable with it!

    I found if you used an NPN transistor at each of the echo pins (B and C pins connected to the echo pin and the E to IO pin3) the echo pin will only connect to IO pin 3 when it goes high and pin 3 will go high as well.

    This seemed to fix it for me but because IO pin 3 is floating at all other times there might be problems.

    0
    Raphango
    Raphango

    4 years ago

    Nice! =D

    0
    andygrove
    andygrove

    4 years ago

    You can buy a breakout board that allows you to connect up to 8 of these HC-SR04 sensors to an Arduino using the SPI protocol, so only one dedicated wire is used.

    http://superawesomerobots.com/product/octasonic-8-x-hc-sr04-breakout-for-arduino/