#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 Color_sensor(IN_1, connection);
Rgb_color color;
int main()
{
try{
cout << "Try to connect to the NXT" << endl;
connection->connect(40);
cout << "Connected" << endl;
cout << "Print sensor RGB-color and color number - hit any key to end" << endl;
while(!_kbhit()){//hit a key to end
cout <<"Print : " << sensor1->print() << endl; //print sensor reading
cout <<"Color number : " << sensor1->read() << endl;
sensor1->read(color);//get raw color reading
cout <<"Raw red : " << color.red << endl;
cout <<"Raw green : " << color.green << endl;
cout <<"Raw blue : " << color.blue << endl;
cout << endl;
Sleep(3000);
}
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();
}
return 0;
}