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()



pinMode(trigPin2, OUTPUT);

pinMode(echoPin2, INPUT);


void loop()


int duration2, distance2;

digitalWrite(trigPin2, HIGH);


digitalWrite(trigPin2, LOW);

duration2 = pulseIn(echoPin2, HIGH);

distance2 = (duration2/2) / 29.1;




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.
Posts: 2
Joined: Sat Aug 13, 2016 4:01 am

Re: Multiple Ultrasonic Sensors

Postby roboalchemist » Thu Apr 06, 2017 8:36 am

It would be probably be better to use a second board - Sparki has pretty sensitive timings that use the timer that pulsein usually uses- that's probably why it's not working.
Joseph Schlesinger - ArcBotics Co-Founder/CTO
Site Admin
Posts: 674
Joined: Mon Jul 16, 2012 3:02 am

Return to Sparki

Who is online

Users browsing this forum: No registered users and 5 guests