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);
}