Description:
In the lab we are working in groups of 3 to 4 members. The partners I’m working with are Johnathan, Garvin and Amarsighn. For this lab we are using phidget to activate sensors.We used C++ program to control phidgets so it can interact with the sensors. We had to test one to two different sensors. We first installed the phidget library by using ubuntu and then we used phidget to test the rotation sensor which is the sensor we are currently using. Depending on the rotation sensor it gives you an output from 1-1000 and as you turn the knob.
//Header #include #include //Event Handler int SensorChangeHandler(CPhidgetInterfaceKitHandle IFK, void *usrptr, int index, int value){ printf("Sensor: %d > value: %d\n", index, value); return 0; } //Main Function int main(int argc, char* argv[]){ //Variable Declarations char input; int val, i; //creates the interface CPhidgetInterfaceKitHandle ifKit = 0; CPhidgetInterfaceKit_create(&ifKit); CPhidget_open((CPhidgetHandle)ifKit, -1); //reads data from all ports that any device is attached CPhidget_waitForAttachment((CPhidgetHandle)ifKit, 10000); //waits for attachment CPhidgetInterfaceKit_set_OnSensorChange_Handler (ifKit, SensorChangeHandler, NULL); //calls function //while loop that will display data until user hits enter. printf("Welcome to my Sensor Reading Program... \n"); printf("Hit Enter to Exit \n"); while(input != '\n') { CPhidgetInterfaceKit_getSensorValue(ifKit, 0, &val); printf("Value: %d\n", val); scanf("%c", &input); } printf("Thank you for using my program... \n"); return 0; }