Push button & Servo robot

Legacy support with Phidget21
Post Reply
Bob
Fresh meat
Posts: 1
Joined: Tue Nov 29, 2016 1:31 pm
Contact:

Push button & Servo robot

Post 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!
User avatar
mparadis
Site Admin
Posts: 660
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: Push button & Servo robot

Post 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).
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests