HC-SR Sensors and Servos :: Member Project

This project using HC-SR sensors and servos was submitted by Troy Yanda, a member of Programming Electronics Academy.

I just finished coding a project I’ve been working on. I’ve been using HC-SR sensors (501 PIR and 04 ultraSonic) in a most recent project.

One problem you run into with the HC-SR04 is if you wanted to trigger an event at a particular distance there is no way to adjust the distance without actually changing the code. I’ve come up with a code to incorporate a potentiometer which will allow you to adjust the distance without having to change the code.

I used the Fritzing software to design and manufacture a PCB (through JLC pcb). I’ve included the schematic, the fabricated PCB and the assembled board.

How the board works

  • After an initial one minute delay (which allows the HC-SR501 to acclimate to the temperature) there’s a brief three second warning beep to indicate that the circuit is about to arm itself.
  • Once it is initially armed the PIR sensor waits to detect any motion.  I put this in first to make sure that the ultraSonic sensor isn’t triggered by some floating debris or such.
  • Once the PIR sensor detects a physical presence it will run through a loop triggering the ultraSonic to start measuring the distance of the presence detected
  • If that presence breaks the set distance set by the potentiometer then the triggered event occurs.
  • In this case a servo is triggered.

 

As you can see this could have many applications. I’m looking forward to using it next year for Halloween on some “triggered tricks”.

Editor Note: Thanks for submitting this awesome project Troy!

Arduino Code:

AppLab Bricks open in background with actual brick

Arduino AppLab Bricks → Marketing Garbage or New Powerful Interface?

Arduino Ventuno single board computer - top side

New Ventuno Q Dual Brain Single Board Computer

AppLab Pip Install

How to Add Python Packages in Arduino AppLab (No pip install needed)

Arduino Power Section Schematic

Kit-on-a-Shield Schematic Review

Just how random is the ESP32 random number generator?

Just how random is the ESP32 random number generator?

4 Comments

  1. Dan Stark on January 17, 2021 at 10:37 pm

    Most interesting…cool

  2. Missi on January 18, 2021 at 8:48 am

    Great job, Troy! You’re a smart guy 🙂

  3. Paul on January 18, 2021 at 2:53 pm

    Excellent programming skills! Easy to read and to follow!

  4. Troy D Yanda on January 18, 2021 at 2:55 pm

    Thanks Dan! I think anyone who uses an 04 sensor will appreciate how user friendly this code will be.

Leave a Comment