#include <cstdlib>
#include <iostream>
#include <string>
#include <conio.h>
#include "nxt.h"
using namespace std;

//set up the NXT
Connection *connection = new Bluetooth();
Sensor *sensor1 = new Light_rcx(IN_1, connection);//percent mode is used
int main()
{
  try{
    cout << "Try to connect to the NXT" << endl;
    connection->connect(40);
    cout << "Connected" << endl;
    while(!_kbhit()){//hit a key to end
      cout << sensor1->print() << endl; //returns a string can be used on all sensor types
      cout << sensor1->read() << endl; // returns a signed value
    }
    connection->disconnect();
  }
  catch (Nxt_exception& e){
    //some error occurred - print it out
    cout << e.what() << endl;
    cout << "error code: " << e.error_code() << endl;
    cout << "error type: " << e.error_type() << endl;
    cout << e.who() << endl;
    connection->disconnect();
  }
  system("pause");
  return 0;
}