Have anyone successfully tried to connect the HC-SR04 sensor to a teensy 3.6 using NewPing library or the library is incompatible? In the library website it is mentioned that is compatible with Teensy family (including Teensy 3.2) but it says nothing about teensy 3.6 I used the code below but I always get "0" distance.
Code:
#include <NewPing.h>
#define TRIGGER_PIN 11
#define ECHO_PIN 10
#define MAX_DISTANCE 400
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
int distance;
void setup() {
Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.
}
void loop() {
unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS).
Serial.print("Ping: ");
distance= uS / US_ROUNDTRIP_CM;
Serial.print(uS / US_ROUNDTRIP_CM); // Convert ping time to distance in cm and print result (0 = outside set distance range)
Serial.println("cm");
}