Welcome to Synthiam!

Program robots using technologies created from industry experts. ARC is our free-to-use robot programming software that makes features like vision recognition, navigation and artificial intelligence easy.

Get Started
Asked — Edited
Resolved Resolved by DJ Sures!

Will The 3 Wire Grove - Ultrasonic Distance Sensor Work On The Arduino Mega

Hello,

I am trying to free up many digital ports on my arduino mega and seen these Grove - Ultrasonic Distance Sensor.  Will they work on my arduino mega?

Thank you in advance.


Edited:  link to Grove - Ultrasonic Distance Sensor
https://www.seeedstudio.com/Grove-Ultrasonic-Distance-Sensor.html?gclid=EAIaIQobChMI5fKn6rOn8wIVPXNvBB1GFgkpEAQYASABEgIsTvD_BwE


Related Hardware Arduino Due/Mega
PRO
Synthiam
#1   — Edited
Looks like it should. Specify the trigger and echo to be on the same port
PRO
USA
#2  
Thanks DJ.  I’m going to order one to test.
Cheers
PRO
USA
#3   — Edited
Hi DJ,

I just tried to use the Grove - Ultrasonic Distance Sensor
 and does not work.  I used the trigger and echo to be on the same port .  I have the version 10-3-21 software.  Do you think you could take a look to see if you can get these working the mega.  I have not tried the EZB 4 1/2 yet.
EDITED: It does not work on the EZB 4 1/2 either.
Edited again:  here’s a copy of Q/A..
Can we connect mulitule ultrasonic to one arduino?

A4: Yes, Here is the example, one sensor is connected to D2 and other to D3.


#include "Ultrasonic.h"

Ultrasonic ultrasonic1(2);
Ultrasonic ultrasonic2(3);
void setup()
{
Serial.begin(9600);
}
void loop()
{
long RangeInCentimeters1;
long RangeInCentimeters2;

RangeInCentimeters1 = ultrasonic1.MeasureInCentimeters(); // two measurements should keep an interval
Serial.print(RangeInCentimeters1);//0~400cm
Serial.println(" cm");

RangeInCentimeters2 = ultrasonic2.MeasureInCentimeters(); // two measurements should keep an interval
Serial.print(RangeInCentimeters2);//0~400cm
Serial.println(" cm");

delay(250);
}


Thank you in advance.
Cheers
PRO
Synthiam
#4  
Try with an ez-robot ez-b first. Because maybe the sensor isn't working. I don't see a reason the sensor shouldn't work for you. The one-wire sensors I have worked fine with the mega. Are you using a digital port? You can't use a servo port. It has to be a digital port.

Remember, a D2 on the EZB Arduino Mega is pin #4. See the mapping here: https://synthiam.com/Support/Hardware/Arduino-Due-Mega

Or press one of the two buttons for viewing the board manual.
User-inserted image




Quote:


Digital Ports
ARC has the ability to select up to 24 Digital ports per EZB. Digital ports also operate as bit-bang serial/uart (transmit only). The MEGA has 21 Digital capable ports mapped to the ARC Digital ports starting from D0 to D20...

(ARC Left, Arduino Right)
D0 = 2,
D1 = 3,
D2 = 4,
D3 = 5,
D4 = 6,
D5 = 7,
D6 = 8,
D7 = 9,
D8 = 10,
D9 = 11,
D10 = 12,
D11 = 13,
D12 = 44,
D13 = 45,
D14 = 46,
D15 = 62,
D16 = 63,
D17 = 64,
D18 = 65,
D19 = 66,
D20 = 67
PRO
Synthiam
#5  
If it isn't working for you on an EZ-Robot EZB, then...

1) Is it getting enough power?

2) Is it wired correctly?

3) Are the correct pins selected?

4) Is it broken?

Those ping sensors are incredibly popular with Synthiam users - I can't see how it isn't working hmmm
PRO
Synthiam
#6  
PS, i added a slight change to the mega firmware that "might" help - it should at least provide higher accuracy as well. Get it from the Arduino Mega hardware page here: https://synthiam.com/Support/Hardware/Arduino-Due-Mega

But if that doesn't work - i'd look into my suggestions above. It might be power-related. These sensors are generally 5v and the Arduino and EZ-B are 3.3v

So you'd need a separate power supply or voltage regulator for ultrasonic sensors like that. Make sure they have common grounds.
PRO
USA
#7   — Edited
You are the man! @DJ,

your firmware was the fix.  They are now working, I testEd 3 of them all good.

BTY, you may have dated the firmware date on purpose or accident. It’s dated November 11, 2021

Thanks again you’re the best!
Cheers