I have just got an Arduino and loving it but I am mystified by one aspect of the library
I have downloaded NewPing and hooked up an HC-SR04 and it works perfectly using this sketch taken off the internet
#include <NewPing.h>
#define TRIGGER_PIN 12
#define ECHO_PIN 11
#define MAX_DISTANCE 200
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
void setup() {
Serial.begin(115200);
}
void loop() {
delay(50);
int uS = sonar.ping();
Serial.print("Ping: ");
Serial.print(uS / US_ROUNDTRIP_CM);
Serial.println("cm");
}
I am going to make some mods to light various leds based on distance from range finder but I am stumped by the line before last which seems to be saying divide uS by something called US_ROUNDTRIP_CM. I am not so much concerned at what it is as my inability to find out where it has come from. (I guess it is used to correct the distance to allow for the full round trip of the sonic pulse out from the range finder and back again)
I am guessing that this is defined in the Library but I cannot find out how to read the library or even if it would make sense if I could read it.
Is a Library a collection of instructions in the same style as a sketch or is it something completely different?
Many thanks to anyone who has the time to help out.