Smartcar Shield
SR04.ino

An example that indicates how to conduct a single measurement with the SR04 ultrasonic sensor and print the results over Serial.

#include <Smartcar.h>
const int TRIGGER_PIN = 6; // D6
const int ECHO_PIN = 7; // D7
const unsigned int MAX_DISTANCE = 100;
ArduinoRuntime arduinoRuntime;
SR04 front(arduinoRuntime, TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
void setup()
{
Serial.begin(9600);
}
void loop()
{
Serial.println(front.getDistance());
delay(100);
}