Grove Ultraosnic Ranger Error

Hi,

While I was coding my code for the grove ultrasonic ranger, it came out with an error. It is something like this.
Error Name: redefinition of 'Ultrasonic ultrasonic'

The code: `#include <Ultrasonic.h>

Ultrasonic ultrasonic (2);/pin2/
Ultrasonic ultrasonic (3);/pin3/
Ultrasonic ultrasonic (4);/pin4/
Ultrasonic ultrasonic (5);/pin5/

void setup() {
Serial.begin(9600);

}

void loop() {
Long RangeInInches;
Long RangeInCentimeters;

if{(ultrasonic.MeasureInCentimeters = 10)
digitalWrite(9,HIGH);
delay(10);
digitalWrite(9,LOW);

}`

Does anybody know what is wrong with my code? By the way, I'm a beginner in Arduino.

Thanks in advance.

Each name MUST be different! You can only have ONE ultrasonic. Name the others something else, like ultrasonic2 or 3 or 4 or?

1 Like

Ok, thank you for your reply. And good news, it works! :grinning:

Yes, that is GOOD news! Glad you are successful.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.