Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
When Logging a Support Issue in the Forum, please ensure you have also:-
  • Enabled vMicro > Compiler > Show Build Properties and Verbose
  • Re-Compile your program with these settings enabled
Save the new Output to a Text File and....
Support requests without the output above may be impossible to answer, so please help us to help you
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
Page Index Toggle Pages: 1
Send Topic Print
Need help with HC-SR04 sensors (Read 164 times)

Posts: 1
Need help with HC-SR04 sensors
Mar 13th, 2020 at 1:45pm
I’m very new to arduino and these types of projects and I’m wondering how I would go about connecting possibly 7 sonars to an arduino along with 7 motors that would vibrate harder as each sonar read closer and closer values. I’m wondering if I will need an extension or something because I don’t know how many ports will be taken up and how many I need. I’m not really sure how setting up more than 3 or 4 works so any help would be greatly appreciated

Back to top
IP Logged

Posts: 126
Re: Need help with HC-SR04 sensors
Reply #1 - Mar 14th, 2020 at 4:32am
For the outputs to drive the motors I would use a PWM expander such as the PCA9685. You might need to improve the output drive capability depending on your motor power. This can be programmed via the I2C bus so only requires 2 pins.

To read from 7 sonars is more interesting. The sonars each require 2 ports, one for trigger and one for the echo return. From a quick look at some Arduino code for using a sonar it uses the pulseIn() function which at a glance looks to be blocking so with 7 sensors your time for managing the trigger/read for the sensors will start to impact on the cycle time of your code loop. So you would need a different approach using interrupts on the echo pins to monitor the return signal from the Echo pin.
Have a look at https://forum.arduino.cc/index.php?topic=494594.0 as this may be a solution.
Back to top
IP Logged
Page Index Toggle Pages: 1
Send Topic Print