#include "Button.h"
#include "Sonar.h"

//	Pins:
const int buttonIn  = 3;
const int buttonOut = 2;

const int redPin    = 10;
const int orangePin = 9;
const int greenPin  = 8;

const int sonarVCC  = 11;
const int sonarTrig = 12;
const int sonarEcho = 13;

//	Components:
Button button(buttonOut, buttonIn, redPin, orangePin, greenPin);
Sonar sonar(sonarVCC, sonarTrig, sonarEcho);

void setup() 
{
  Serial.begin(9600);
}

void loop() 
{
  delay(30);                      //  Implement a delay so the Arduino doesn't run too fast for it's own good.

  if   (button.measure()) return; //  Measure the button's input, and have it's data sent to the serial port.
  sonar.measure();                //  If the button is not pressed, measure the sonar, and have it's data sent to the serial port.
}