 typedef struct StateStruct {
 	bool active;
 	bool motionDetected;
-	bool sonarDetected;
 	bool buttonPressed;
-	unsigned long sonarDistanceDetected;
 	uint32_t lastActivityAt;
 	uint32_t lastStateChangeAt;
 } CurrentState;
 
 CurrentState state;
+bool ledOn;
 
 void power(bool on) {
 	digitalWrite(pinSwitch, on ? HIGH : LOW);

#include "printf.h"

#include "Sonar.h"
#include "MotionSensor.h"

#include <SimpleTimer.h>

// #define DEBUG

uint8_t	pinIRInput 		= 11,
		pinSonarTrigger = 9,
		pinSonarEcho 	= 10,
		pinSwitch 		= 13,
		pinButton		= 8
		;

Sonar sonar(
		pinSonarTrigger,
		pinSonarEcho,
		500,				   // Maximum distance we want to ping for (in centimeters).
			  	  	  	  	   // Maximum sensor distance is rated at 400-500cm.
		100);   // Recognize objects within this many centimeters

MotionSensor motion(pinIRInput, 5000);
SimpleTimer timer(1);


const uint16_t INACTIVITY_THRESHOLD = 120;


	memset(&state, 0x0, sizeof(StateStruct));

	pinMode(pinSwitch, OUTPUT);
	pinMode(pinLed, OUTPUT);
	pinMode(pinButton, INPUT);
	pinMode(pinIRInput, INPUT);

