//gcc -Wall -g -o "%e" "%f"  -lfreenect -lfreenect_sync   
#include <libfreenect.h>
#include <libfreenect_sync.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>  //tcgetattr and sleep

int count = 0;  //counter for tilt
void no_kinect_quit(void){
	printf("Error: Kinect not connected?\n");
	exit(1);
}

int main(int argc, char *argv[]){
	while (1) {
//pan back and forth mindlessly
	//	int tilt = count;  // -15 to 14
for (int count =0 ; count<=16; count+=2){
		// Set the tilt angle (in degrees)
		if (freenect_sync_set_tilt_degs(count, 0)) no_kinect_quit();
	        printf("tilt[%d] \n", count);
			sleep(1);
            }
for (int count = 16; count>= -16 ; count-=2){
		// Set the tilt angle (in degrees)
		if (freenect_sync_set_tilt_degs(count, 0)) no_kinect_quit();
			printf("tilt[%d] \n", count);
			sleep(1);
            }
       }
}