Thanks!
Jerry
Code: Select all
PhidgetLog_enable(PHIDGET_LOG_INFO, NULL);
PhidgetDCMotorHandle dcmotor1;
PhidgetDCMotorHandle dcmotor2;
PhidgetDCMotor_create(&dcmotor1);
PhidgetDCMotor_create(&dcmotor2);
Phidget_setDeviceSerialNumber((PhidgetHandle)dcmotor1, STEERING_AND_THROTTLE_PHIDGET_SERIAL_NUMBER);
Phidget_setDeviceSerialNumber((PhidgetHandle)dcmotor2, STEERING_AND_THROTTLE_PHIDGET_SERIAL_NUMBER);
Phidget_setChannel((PhidgetHandle)dcmotor1, 0);
Phidget_setChannel((PhidgetHandle)dcmotor2, 1);
Phidget_openWaitForAttachment((PhidgetHandle)dcmotor1, 5000);
Phidget_openWaitForAttachment((PhidgetHandle)dcmotor2, 5000);
PhidgetDCMotor_setTargetVelocity(dcmotor1, 1);
PhidgetDCMotor_setTargetVelocity(dcmotor2, 1);
sleep(2.5);
PhidgetDCMotor_setTargetVelocity(dcmotor1, -1);
PhidgetDCMotor_setTargetVelocity(dcmotor2, -1);
sleep(2.5);
PhidgetDCMotor_setTargetVelocity(dcmotor1, 0);
PhidgetDCMotor_setTargetVelocity(dcmotor2, 0);
PhidgetDCMotor_delete(&dcmotor1);
PhidgetDCMotor_delete(&dcmotor2);