Page 1 of 1

Push button & Servo robot

Posted: Tue Nov 29, 2016 1:53 pm
by Bob
Two quick questions:
1) What code would I need to cause a push button to flash an LED light bulb everytime the button is pushed? Would I need to alter a sample code from phidgets?

2) What does this following code do to the servo robot?

Code: Select all

 calllib('phidget21', 'CPhidgetAdvancedServo_setEngaged', handle, 1, 0); 
I assume something with the movement? or Activating it maybe?

Thanks!

Re: Push button & Servo robot

Posted: Wed Nov 30, 2016 9:57 am
by mparadis
1) Yes, you can modify some sample code to do what you've described. Find the InterfaceKit example for the language you're using and find the digital input change handler. In that function, check to see if the input being changed is the one the button is connected to, and then turn the digital output on that the LED is connected to (you should be able to find an example of turning on a digital output elsewhere in the sample code).

2) setEngaged turns on or turns off power to the servo motor. In this case, it's turning the power off, since the last parameter is a zero. The parameter before that is the index of the servo to switch on or off. This is different than telling the servo to stop, because when stopped the servo will still expend power trying to hold its position even if an external force tries to move it. When disengaged, a servo will not try to hold position (although the friction of the gearbox will still provide some resistance).