Multiple Ultrasonic Sensors

The Easy Robot for Everyone!

Multiple Ultrasonic Sensors

Postby torstenvolk » Sat Aug 13, 2016 4:13 am

What do I need to change to be able to enable Sparki.h and use multiple ultrasonic sensors. Currently, I can only get the old OR the new sensor to work: When I #include Sparki.h the below code simply will not work. Can anyone tell me what I need to change in the sparki library to get both sensors to work?

Here's the code I'm using. I have also tried this using ports 0 and 1 and the result is always the same: When I don't #include Sparki.h, the 2nd sensor works, but when I put back Sparki.h, it doesn't. Where is the conflict??? Thanks so much for your help!

#define trigPin2 3
#define echoPin2 2
#include <Sparki.h>
void setup()

{

Serial.begin(9600);

pinMode(trigPin2, OUTPUT);

pinMode(echoPin2, INPUT);

}

void loop()

{

int duration2, distance2;

digitalWrite(trigPin2, HIGH);

delayMicroseconds(2000);

digitalWrite(trigPin2, LOW);

duration2 = pulseIn(echoPin2, HIGH);

distance2 = (duration2/2) / 29.1;

Serial.println(distance2);

Serial.print("cm");

delay(500);

}
torstenvolk
 
Posts: 2
Joined: Sat Aug 13, 2016 4:01 am

Re: Multiple Ultrasonic Sensors

Postby torstenvolk » Tue Mar 14, 2017 4:27 am

I'm still stuck with my stupid question on adding multiple PING sensors. Clearly I'm not the biggest Arduino experts, but I'd love an answer of whether it's worth trying to get this figured out? Could I add a "trunk" with an extra Arduino Uno board and use the RX/TX pins? I'd also love to be able to add more sensors in general.
torstenvolk
 
Posts: 2
Joined: Sat Aug 13, 2016 4:01 am


Return to Sparki

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 9 guests

cron