#include <Arduino.h>

#define SENDER_GND    10
#define SENDER_DATA   11
#define SENDER_VCC    12
#define TRIGGER_PIN   2
#define ECHO_PIN      3
#define NOTIFY_PIN    9

#define MAX_DISTANCE  200		// 2 meters

#include "SonarSensor.h"

SonarSensor oilSensor(OIL_SENSOR);

void setup() {
	Serial.begin(9600);
	Serial.println("starting...");

	pinMode(SENDER_GND, OUTPUT);
	digitalWrite(SENDER_GND, LOW);
	pinMode(SENDER_VCC, OUTPUT);
	digitalWrite(SENDER_VCC, HIGH);
	TinySwitch::setup(SENDER_DATA);

	delay(300);
	unsigned int distance = oilSensor.scan();
	Serial.println(distance);
	if (distance) oilSensor.sendValueAndVoltage(distance);
	delay(200);
	pinMode(NOTIFY_PIN, OUTPUT);
	digitalWrite(NOTIFY_PIN, LOW);
	Serial.println("finished");
}

void loop() {
}
